下面是代码。
const bitcoin = require('bitcoinjs-lib'); 让testnet = bitcoin.networks.testnet;
let keypair = bitcoin.ECPair.makeRandom({network: testnet});
let addr = keypair.getAddress();
let pk = keypair.toWIF();
答案 0 :(得分:2)
您尝试过吗:
class ExternalClass
{
public int ExternalMethod(int input)
{
// do a thing
}
}
public class WrapperClass
{
private ExternalClass external;
public WrapperClass(ExternalClass external)
{
this.external = external;
}
public int WrapperMethod(int input) {
// do the verification or checks that you need here
return this.external(input);
}
}
这似乎是the definitive example at github所做的。
答案 1 :(得分:2)
只需将网络参数直接传递给ECPair.makeRandom即可,而无需包装对象,您将在那里:)
const bitcoin = require('bitcoinjs-lib');
let testnet = bitcoin.networks.testnet;
let keypair = bitcoin.ECPair.makeRandom(testnet);
let addr = keypair.getAddress();
let pk = keypair.toWIF();