本文整理汇总了Java中com.google.bitcoin.core.DumpedPrivateKey类的典型用法代码示例。如果您正苦于以下问题:Java DumpedPrivateKey类的具体用法?Java DumpedPrivateKey怎么用?Java DumpedPrivateKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DumpedPrivateKey类属于com.google.bitcoin.core包,在下文中一共展示了DumpedPrivateKey类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parsePrivateKey
import com.google.bitcoin.core.DumpedPrivateKey; //导入依赖的package包/类
public static ECKey parsePrivateKey(String format, String contents, String password) throws Exception {
if (format.equals("sipa") || format.equals("compsipa")) {
DumpedPrivateKey pk = new DumpedPrivateKey(MainNetParams.get(), contents);
return pk.getKey();
} else if (format.equals("base58")) {
return MyWallet.decodeBase58PK(contents);
} else if (format.equals("base64")) {
return MyWallet.decodeBase64PK(contents);
} else if (format.equals("hex")) {
return MyWallet.decodeHexPK(contents);
}else if (format.equals("bip38")) {
return parseBIP38 (contents, password);
} else {
throw new Exception("Unable to handle format " + format);
}
}
示例2: verify
import com.google.bitcoin.core.DumpedPrivateKey; //导入依赖的package包/类
public ECKey verify(String input) throws WrongInputException {
try {
ECKey sk = new DumpedPrivateKey(params, input).getKey();
if (pkHash != null && !Arrays.equals(sk.getPubKeyHash(), pkHash)) {
throw new WrongInputException("The secret key does not correspond expected public key.");
}
return sk;
} catch (AddressFormatException e) {
throw new WrongInputException("Wrong format of the secret key.");
}
}
示例3: importKey
import com.google.bitcoin.core.DumpedPrivateKey; //导入依赖的package包/类
public static ECKey importKey(String privkey) throws Exception {
//only accepts a very specific type of address. from dumpprivkey functionality in Bitcoin core.
DumpedPrivateKey dump = new DumpedPrivateKey(Constants.NETWORK_PARAMETERS, privkey);
return dump.getKey();
// ECKey key = dump.getKey();
// return key.toAddress(NETWORK_PARAMETERS);
// return key.getPubKey();
}
示例4: generate
import com.google.bitcoin.core.DumpedPrivateKey; //导入依赖的package包/类
public Address generate() throws AddressFormatException {
ECKey key = new DumpedPrivateKey(params, privKeys[(privKeyCounter++)
% privKeys.length]).getKey();
wallet.addKey(key);
byte[] pubKeyHash = key.getPubKeyHash();
return new Address(params, pubKeyHash);
}
示例5: importPrivateKey
import com.google.bitcoin.core.DumpedPrivateKey; //导入依赖的package包/类
public Address importPrivateKey(String privKey)
throws AddressFormatException {
ECKey key = new DumpedPrivateKey(params, privKey).getKey();
wallet.addKey(key);
byte[] pubKeyHash = key.getPubKeyHash();
return new Address(params, pubKeyHash);
}