本文整理了Java中org.bitcoinj.core.Address.getParameters()
方法的一些代码示例,展示了Address.getParameters()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getParameters()
方法的具体详情如下:
包路径:org.bitcoinj.core.Address
类名称:Address
方法名:getParameters
[英]Examines the version byte of the address and attempts to find a matching NetworkParameters. If you aren't sure which network the address is intended for (eg, it was provided by a user), you can use this to decide if it is compatible with the current wallet. You should be able to handle a null response from this method. Note that the parameters returned is not necessarily the same as the one the Address was created with.
[中]检查地址的版本字节并尝试查找匹配的NetworkParameters。如果您不确定该地址用于哪个网络(例如,它是由用户提供的),您可以使用该地址来确定它是否与当前钱包兼容。您应该能够处理来自此方法的空响应。请注意,返回的参数不一定与创建地址时使用的参数相同。
代码示例来源:origin: greenaddress/GreenBits
/**
* Returns true if this address is a Pay-To-Script-Hash (P2SH) address.
* See also https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki: Address Format for pay-to-script-hash
*/
public boolean isP2SHAddress() {
final NetworkParameters parameters = getParameters();
return parameters != null && this.version == parameters.p2shHeader;
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Returns true if this address is a Pay-To-Witness-Script-Hash (P2WSH) address.
* See also https://github.com/bitcoin/bips/blob/master/bip-0142.mediawiki: Address Format for Segregated Witness
*/
public boolean isP2WSHAddress() {
final NetworkParameters parameters = getParameters();
return parameters != null && this.version == parameters.p2wshHeader;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Returns true if this address is a Pay-To-Script-Hash (P2SH) address.
* See also https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki: Address Format for pay-to-script-hash
*/
public boolean isP2SHAddress() {
final NetworkParameters parameters = getParameters();
return parameters != null && this.version == parameters.p2shHeader;
}
代码示例来源:origin: HashEngineering/dashj
/**
* Returns true if this address is a Pay-To-Script-Hash (P2SH) address.
* See also https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki: Address Format for pay-to-script-hash
*/
public boolean isP2SHAddress() {
final NetworkParameters parameters = getParameters();
return parameters != null && this.version == parameters.p2shHeader;
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Returns true if this address is a Pay-To-Script-Hash (P2SH) address.
* See also https://github.com/bitcoin/bips/blob/master/bip-0013.mediawiki: Address Format for pay-to-script-hash
*/
public boolean isP2SHAddress() {
final NetworkParameters parameters = getParameters();
return parameters != null && this.version == parameters.p2shHeader;
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Returns true if this address is a Pay-To-Witness-Public-Key-Hash (P2WPKH) address.
* See also https://github.com/bitcoin/bips/blob/master/bip-0142.mediawiki: Address Format for Segregated Witness
*/
public boolean isP2WPKHAddress() {
final NetworkParameters parameters = getParameters();
return parameters != null && this.version == parameters.p2wpkhHeader;
}
代码示例来源:origin: HashEngineering/dashj
/**
* Given an address, examines the version byte and attempts to find a matching NetworkParameters. If you aren't sure
* which network the address is intended for (eg, it was provided by a user), you can use this to decide if it is
* compatible with the current wallet.
* @return a NetworkParameters of the address
* @throws AddressFormatException if the string wasn't of a known version
*/
public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException {
try {
return Address.fromBase58(null, address).getParameters();
} catch (WrongNetworkException e) {
throw new RuntimeException(e); // Cannot happen.
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Given an address, examines the version byte and attempts to find a matching NetworkParameters. If you aren't sure
* which network the address is intended for (eg, it was provided by a user), you can use this to decide if it is
* compatible with the current wallet.
* @return a NetworkParameters of the address
* @throws AddressFormatException if the string wasn't of a known version
*/
public static NetworkParameters getParametersFromAddress(String address) throws AddressFormatException {
try {
return Address.fromBase58(null, address).getParameters();
} catch (WrongNetworkException e) {
throw new RuntimeException(e); // Cannot happen.
}
}
代码示例来源:origin: HashEngineering/dashj
/**
* Simple Bitcoin URI builder using known good fields.
*
* @param address The Bitcoin address
* @param amount The amount
* @param label A label
* @param message A message
* @return A String containing the Bitcoin URI
*/
public static String convertToBitcoinURI(Address address, Coin amount,
String label, String message) {
return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message);
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Simple Bitcoin URI builder using known good fields.
*
* @param address The Bitcoin address
* @param amount The amount
* @param label A label
* @param message A message
* @return A String containing the Bitcoin URI
*/
public static String convertToBitcoinURI(Address address, Coin amount,
String label, String message) {
return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message);
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Simple Bitcoin URI builder using known good fields.
*
* @param address The Bitcoin address
* @param amount The amount
* @param label A label
* @param message A message
* @return A String containing the Bitcoin URI
*/
public static String convertToBitcoinURI(Address address, Coin amount,
String label, String message) {
return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message);
}
代码示例来源:origin: Coinomi/coinomi-android
BitAddress(Address address) throws WrongNetworkException {
this((CoinType) address.getParameters(), address.getVersion(), address.getHash160());
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Simple Bitcoin URI builder using known good fields.
*
* @param address The Bitcoin address
* @param amount The amount
* @param label A label
* @param message A message
* @return A String containing the Bitcoin URI
*/
public static String convertToBitcoinURI(Address address, Coin amount,
String label, String message) {
return convertToBitcoinURI(address.getParameters(), address.toString(), amount, label, message);
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
public static SendRequest emptyWallet(Address destination) {
SendRequest req = new SendRequest();
final NetworkParameters parameters = destination.getParameters();
checkNotNull(parameters, "Address is for an unknown network");
req.tx = new Transaction(parameters);
req.tx.addOutput(Coin.ZERO, destination);
req.emptyWallet = true;
return req;
}
代码示例来源:origin: HashEngineering/dashj
public static SendRequest emptyWallet(Address destination) {
SendRequest req = new SendRequest();
final NetworkParameters parameters = destination.getParameters();
checkNotNull(parameters, "Address is for an unknown network");
req.tx = new Transaction(parameters);
req.tx.addOutput(Coin.ZERO, destination);
req.emptyWallet = true;
return req;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
public static SendRequest emptyWallet(Address destination) {
SendRequest req = new SendRequest();
final NetworkParameters parameters = destination.getParameters();
checkNotNull(parameters, "Address is for an unknown network");
req.tx = new Transaction(parameters);
req.tx.addOutput(Coin.ZERO, destination);
req.emptyWallet = true;
return req;
}
代码示例来源:origin: greenaddress/GreenBits
public static SendRequest emptyWallet(Address destination) {
SendRequest req = new SendRequest();
final NetworkParameters parameters = destination.getParameters();
checkNotNull(parameters, "Address is for an unknown network");
req.tx = new Transaction(parameters);
req.tx.addOutput(Coin.ZERO, destination);
req.emptyWallet = true;
return req;
}
代码示例来源:origin: HashEngineering/dashj
/**
* <p>Creates a new SendRequest to the given address for the given value.</p>
*
* <p>Be very careful when value is smaller than {@link Transaction#MIN_NONDUST_OUTPUT} as the transaction will
* likely be rejected by the network in this case.</p>
*/
public static SendRequest to(Address destination, Coin value) {
SendRequest req = new SendRequest();
final NetworkParameters parameters = destination.getParameters();
checkNotNull(parameters, "Address is for an unknown network");
req.tx = new Transaction(parameters);
req.tx.addOutput(value, destination);
return req;
}
代码示例来源:origin: greenaddress/GreenBits
@Test(expected = java.lang.IllegalStateException.class)
public void sendCoinsNoBroadcasterTest() throws InsufficientMoneyException {
ECKey key = ECKey.fromPrivate(BigInteger.TEN);
SendRequest req = SendRequest.to(OTHER_ADDRESS.getParameters(), key, SATOSHI.multiply(12));
wallet.sendCoins(req);
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void sendCoinsWithBroadcasterTest() throws InsufficientMoneyException {
ECKey key = ECKey.fromPrivate(BigInteger.TEN);
receiveATransactionAmount(wallet, myAddress, Coin.COIN);
MockTransactionBroadcaster broadcaster = new MockTransactionBroadcaster(wallet);
wallet.setTransactionBroadcaster(broadcaster);
SendRequest req = SendRequest.to(OTHER_ADDRESS.getParameters(), key, Coin.CENT);
wallet.sendCoins(req);
}
内容来源于网络,如有侵权,请联系作者删除!