/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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. } }
/** * 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. } }
/** * 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); }
/** * 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); }
/** * 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); }
BitAddress(Address address) throws WrongNetworkException { this((CoinType) address.getParameters(), address.getVersion(), address.getHash160()); }
/** * 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); }
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; }
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; }
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; }
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; }
/** * <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; }
@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); }
@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); }