This repository was archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
This repository was archived by the owner on Nov 21, 2024. It is now read-only.
转账支持BLS Public Key Address (f3开头的地址) #9
Copy link
Copy link
Open
Description
我修改后,转账失败。不知道什么地方错了。用的是ganache-filecoin 做开发用的api服务。
- 报错信息
Exception in thread "main" com.filecoinj.exception.SendException: send error {"id":1,"jsonrpc":"2.0","error":{"message":"Cannot read property 'value' of undefined","stack":"TypeError: Cannot read property 'value' of undefined\n at sigCacheKey (C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\@ganache\\filecoin\\dist\\node\\ganache-filecoin.min.js:2:804447)\n at verifyMessageSignature (C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\@ganache\\filecoin\\dist\\node\\ganache-filecoin.min.js:2:804531)\n at Object.checkMessage (C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\@ganache\\filecoin\\dist\\node\\ganache-filecoin.min.js:2:805672)\n at Blockchain.pushSigned (C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\@ganache\\filecoin\\dist\\node\\ganache-filecoin.min.js:2:778470)\n at FilecoinApi.Filecoin.MpoolPush (C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\@ganache\\filecoin\\dist\\node\\ganache-filecoin.min.js:2:764697)\n at C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache\\dist\\node\\ganache.min.js:2:3790243\n at RequestCoordinator.<anonymous> (C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache\\dist\\node\\ganache.min.js:2:3790075)\n at C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache\\dist\\node\\ganache.min.js:2:3790310\n at new Promise (<anonymous>)\n at RequestCoordinator.queue (C:\\Program Files\\WindowsApps\\GanacheUI_2.6.0.0_x64__5dg5pnz03psnj\\app\\resources\\static\\node\\node_modules\\ganache\\dist\\node\\ganache.min.js:2:3790173)","code":-32700}}
- AddressUtil.java修改后代码
package com.filecoinj.utils;
import cn.hutool.core.codec.Base32;
import cn.hutool.core.util.StrUtil;
import com.filecoinj.exception.AddressException;
import com.filecoinj.model.Address;
public class AddressUtil {
/**
* secp256k1地址字节长度
*/
private final static int addressLength_1 = 21;
// private final static int addressLength_1 = 21;
private final static int addressLength_3 = 43;
public static Address initAddress(String addressStr) throws AddressException {
if (StrUtil.isBlank(addressStr)){
throw new NullPointerException("addressStr 参数不能为空");
}
//去掉拼接的前两位
String substring = addressStr.substring(2);
//获取type
String typeStr = addressStr.substring(1, 2);
//获取网络类型
String network = addressStr.substring(0,1);
int type = Integer.parseInt(typeStr);
if (type != 1 && type !=2 && type != 3){
throw new AddressException("错误的地址类型");
}
int addrLen = addressLength_1;
if(type==3){
addrLen = addressLength_3;
}
byte[] addressBytes = new byte[addrLen];
// f099
// f1abjxfbp274xpdqcpuaykwkfb43omjotacm2p3za
// f2plku564ddywnmb5b2ky7dhk4mb6uacsxuuev3pi
// f3tfhgkbq6h55fqhumadd7wvogx3bbhgm3ifg6mk6hq35ob3fex2uei7hfbo2nwqkzudjzjidmshxpvo3ja4iq
switch (type){
case 1:
//secp256k1 地址类型
addressBytes[0] = (byte) type;
break;
case 2:
case 3:
// throw new AddressException("暂不支持的地址类型");
addressBytes[0] = (byte) type;
break;
default:
throw new AddressException("错误地址类型");
}
System.arraycopy(Base32.decode(substring), 0, addressBytes, 1, addrLen-1);
return Address.builder().address(addressStr)
.bytes(addressBytes)
.network(network).build();
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels