本文整理了Java中org.bitcoinj.core.Address.<init>()
方法的一些代码示例,展示了Address.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.<init>()
方法的具体详情如下:
包路径:org.bitcoinj.core.Address
类名称:Address
方法名:<init>
[英]Construct an address from parameters, the address version, and the hash160 form. Example:
new Address(MainNetParams.get(), NetworkParameters.getAddressHeader(), Hex.decode("4a22c3c4cbb31e4d03b15550636762bda0baf85a"));
[中]根据参数、地址版本和哈希表构造地址。例子:
new Address(MainNetParams.get(), NetworkParameters.getAddressHeader(), Hex.decode("4a22c3c4cbb31e4d03b15550636762bda0baf85a"));
代码示例来源:origin: DanielKrawisz/Shufflepuff
public static boolean isValidAddress(String address, NetworkParameters params) {
try {
new Address(params, address);
return true;
} catch (AddressFormatException e) {
return false;
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/** Returns an Address that represents the given P2SH script hash. */
public static Address fromP2SHHash(NetworkParameters params, byte[] hash160) {
try {
return new Address(params, params.getP2SHHeader(), hash160);
} catch (WrongNetworkException e) {
throw new RuntimeException(e); // Cannot happen.
}
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/** Returns an Address that represents the given P2SH script hash. */
public static Address fromP2SHHash(NetworkParameters params, byte[] hash160) {
try {
return new Address(params, params.getP2SHHeader(), hash160);
} catch (WrongNetworkException e) {
throw new RuntimeException(e); // Cannot happen.
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Returns the address that corresponds to the public part of this ECKey. Note that an address is derived from
* the RIPEMD-160 hash of the public key and is not the public key itself (which is too large to be convenient).
*/
public Address toAddress(NetworkParameters params) {
return new Address(params, getPubKeyHash());
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Returns the address that corresponds to the public part of this ECKey. Note that an address is derived from
* the RIPEMD-160 hash of the public key and is not the public key itself (which is too large to be convenient).
*/
public Address toAddress(NetworkParameters params) {
return new Address(params, getPubKeyHash());
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Returns the address that corresponds to the public part of this ECKey. Note that an address is derived from
* the RIPEMD-160 hash of the public key and is not the public key itself (which is too large to be convenient).
*/
public Address toAddress(NetworkParameters params) {
return new Address(params, getPubKeyHash());
}
代码示例来源:origin: greenaddress/GreenBits
/** Returns an Address that represents the given P2WPKH public key hash. */
public static Address fromP2WPKHHash(NetworkParameters params, byte[] hash) {
try {
return new Address(params, params.getP2WPKHHeader(), hash);
} catch (WrongNetworkException e) {
throw new RuntimeException(e);
} catch (WrongLengthException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: HashEngineering/dashj
/** Returns an Address that represents the given P2SH script hash. */
public static Address fromP2SHHash(NetworkParameters params, byte[] hash160) {
try {
return new Address(params, params.getP2SHHeader(), hash160);
} catch (WrongNetworkException e) {
throw new RuntimeException(e); // Cannot happen.
}
}
代码示例来源:origin: Multibit-Legacy/multibit-hardware
/**
* @param rawAddress The raw address as provided by the device
*/
public MainNetAddress(String rawAddress) {
try {
this.address = Optional.of(new Address(MainNetParams.get(), rawAddress));
} catch (AddressFormatException e) {
log.warn("Invalid MainNet address. Ignoring.");
}
}
代码示例来源:origin: greenaddress/GreenBits
/** Returns an Address that represents the given P2SH script hash. */
public static Address fromP2SHHash(NetworkParameters params, byte[] hash160) {
try {
return new Address(params, params.getP2SHHeader(), hash160);
} catch (WrongNetworkException e) {
throw new RuntimeException(e); // Cannot happen.
}
}
代码示例来源:origin: greenaddress/GreenBits
/** Returns an Address that represents the given P2WSH script hash. */
public static Address fromP2WSHHash(NetworkParameters params, byte[] hash) {
try {
return new Address(params, params.getP2WSHHeader(), hash);
} catch (WrongNetworkException e) {
throw new RuntimeException(e);
} catch (WrongLengthException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* For 2-element [input] scripts assumes that the paid-to-address can be derived from the public key.
* The concept of a "from address" isn't well defined in Bitcoin and you should not assume the sender of a
* transaction can actually receive coins on it. This method may be removed in future.
*/
@Deprecated
public Address getFromAddress(NetworkParameters params) throws ScriptException {
return new Address(params, Utils.sha256hash160(getPubKey()));
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* For 2-element [input] scripts assumes that the paid-to-address can be derived from the public key.
* The concept of a "from address" isn't well defined in Bitcoin and you should not assume the sender of a
* transaction can actually receive coins on it. This method may be removed in future.
*/
@Deprecated
public Address getFromAddress(NetworkParameters params) throws ScriptException {
return new Address(params, Utils.sha256hash160(getPubKey()));
}
代码示例来源:origin: HashEngineering/dashj
/**
* For 2-element [input] scripts assumes that the paid-to-address can be derived from the public key.
* The concept of a "from address" isn't well defined in Bitcoin and you should not assume the sender of a
* transaction can actually receive coins on it. This method may be removed in future.
*/
@Deprecated
public Address getFromAddress(NetworkParameters params) throws ScriptException {
return new Address(params, Utils.sha256hash160(getPubKey()));
}
代码示例来源:origin: greenaddress/GreenBits
/**
* For 2-element [input] scripts assumes that the paid-to-address can be derived from the public key.
* The concept of a "from address" isn't well defined in Bitcoin and you should not assume the sender of a
* transaction can actually receive coins on it. This method may be removed in future.
*/
@Deprecated
public Address getFromAddress(NetworkParameters params) throws ScriptException {
return new Address(params, Utils.sha256hash160(getPubKey()));
}
代码示例来源:origin: DanielKrawisz/Shufflepuff
public AddressImpl(String address) throws FormatException {
try {
this.address = new org.bitcoinj.core.Address(
org.bitcoinj.core.Address.getParametersFromAddress(address), address);
} catch (AddressFormatException e) {
throw new FormatException("Could not parse address " + address);
}
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void basicSpendingToP2SH() throws Exception {
Address destination = new Address(PARAMS, PARAMS.getP2SHHeader(), HEX.decode("4a22c3c4cbb31e4d03b15550636762bda0baf85a"));
basicSpendingCommon(wallet, myAddress, destination, null);
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void cloning() throws Exception {
Address a = new Address(testParams, HEX.decode("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc"));
Address b = a.clone();
assertEquals(a, b);
assertNotSame(a, b);
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void stringification() throws Exception {
// Test a testnet address.
Address a = new Address(testParams, HEX.decode("fda79a24e50ff70ff42f7d89585da5bd19d9e5cc"));
assertEquals("n4eA2nbYqErp7H6jebchxAN59DmNpksexv", a.toString());
assertFalse(a.isP2SHAddress());
Address b = new Address(mainParams, HEX.decode("4a22c3c4cbb31e4d03b15550636762bda0baf85a"));
assertEquals("17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL", b.toString());
assertFalse(b.isP2SHAddress());
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void testScriptPubKey() throws Exception {
// Check we can extract the to address
byte[] pubkeyBytes = HEX.decode(pubkeyProg);
Script pubkey = new Script(pubkeyBytes);
assertEquals("DUP HASH160 PUSHDATA(20)[33e81a941e64cda12c6a299ed322ddbdd03f8d0e] EQUALVERIFY CHECKSIG", pubkey.toString());
Address toAddr = new Address(PARAMS, pubkey.getPubKeyHash());
assertEquals("mkFQohBpy2HDXrCwyMrYL5RtfrmeiuuPY2", toAddr.toString());
}
内容来源于网络,如有侵权,请联系作者删除!