引入最新版本bitcoinj包
api 'org.bitcoinj:bitcoinj-core:0.16.1'
api 'org.slf4j:slf4j-api:1.7.32'
1、根据助记词创建btc钱包
val BITCOINJ_NETWORK_PARAMETERS: NetworkParameters =
if (BuildConfig.DEBUG) TestNet3Params.get() else MainNetParams.get()
public static ImmutableList<ChildNumber> generatePath(String path) {
List<ChildNumber> list = new ArrayList<>();
for (String p : path.split("/")) {
if ("m".equalsIgnoreCase(p) || "".equals(p.trim())) {
continue;
} else if (p.charAt(p.length() - 1) == '\'') {
list.add(new ChildNumber(Integer.parseInt(p.substring(0, p.length() - 1)), true));
} else {
list.add(new ChildNumber(Integer.parseInt(p), false));
}
}
|