本文整理了Java中org.bitcoinj.core.Utils.sha256hash160()
方法的一些代码示例,展示了Utils.sha256hash160()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.sha256hash160()
方法的具体详情如下:
包路径:org.bitcoinj.core.Utils
类名称:Utils
方法名:sha256hash160
[英]Calculates RIPEMD160(SHA256(input)). This is used in Address calculations.
[中]计算RIPEMD160(SHA256(输入))。这用于地址计算。
代码示例来源:origin: fr.acinq/bitcoinj-core
/** Gets the hash160 form of the public key (as seen in addresses). */
public byte[] getPubKeyHash() {
if (pubKeyHash == null)
pubKeyHash = Utils.sha256hash160(this.pub.getEncoded());
return pubKeyHash;
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/**
* Returns RIPE-MD160(SHA256(pub key bytes)).
*/
public byte[] getIdentifier() {
return Utils.sha256hash160(getPubKey());
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Returns RIPE-MD160(SHA256(pub key bytes)).
*/
public byte[] getIdentifier() {
return Utils.sha256hash160(getPubKey());
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
/** Gets the hash160 form of the public key (as seen in addresses). */
public byte[] getPubKeyHash() {
if (pubKeyHash == null)
pubKeyHash = Utils.sha256hash160(this.pub.getEncoded());
return pubKeyHash;
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Returns RIPE-MD160(SHA256(pub key bytes)).
*/
public byte[] getIdentifier() {
return Utils.sha256hash160(getPubKey());
}
代码示例来源:origin: greenaddress/GreenBits
/** Gets the hash160 form of the public key (as seen in addresses). */
public byte[] getPubKeyHash() {
if (pubKeyHash == null)
pubKeyHash = Utils.sha256hash160(this.pub.getEncoded());
return pubKeyHash;
}
代码示例来源:origin: HashEngineering/dashj
/** Gets the hash160 form of the public key (as seen in addresses). */
public byte[] getPubKeyHash() {
if (pubKeyHash == null)
pubKeyHash = Utils.sha256hash160(this.pub.getEncoded());
return pubKeyHash;
}
代码示例来源: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: 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: cash.bitcoinj/bitcoinj-core
/**
* Creates a scriptPubKey for the given redeem script.
*/
public static Script createP2SHOutputScript(Script redeemScript) {
byte[] hash = Utils.sha256hash160(redeemScript.getProgram());
return ScriptBuilder.createP2SHOutputScript(hash);
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Creates a scriptPubKey for the given redeem script.
*/
public static Script createP2SHOutputScript(Script redeemScript) {
byte[] hash = Utils.sha256hash160(redeemScript.getProgram());
return ScriptBuilder.createP2SHOutputScript(hash);
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Creates a scriptPubKey for the given redeem script.
*/
public static Script createP2SHOutputScript(Script redeemScript) {
byte[] hash = Utils.sha256hash160(redeemScript.getProgram());
return ScriptBuilder.createP2SHOutputScript(hash);
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Returns true if this script is P2SH wrapping P2WPKH for provided key.
* @param pubKey
* @return
*/
public boolean isSentToP2WPKHP2SH(ECKey pubKey) {
byte[] scriptHash = Utils.sha256hash160(ScriptBuilder.createP2WPKHOutputScript(pubKey).getProgram());
return (isPayToScriptHash() && Arrays.equals(scriptHash, getPubKeyHash()));
}
代码示例来源:origin: fr.acinq/bitcoinj-core
/**
* Returns true if this is a P2SH pubKeyScript wrapping a P2WSH redeem script for provided segwit script.
* @param script
* @return
*/
public boolean isSentToP2WSHP2SH(Script script) {
Script segwitProgram = ScriptBuilder.createP2WSHOutputScript(script);
byte[] scriptHash = Utils.sha256hash160(segwitProgram.getProgram());
return (isPayToScriptHash() && Arrays.equals(scriptHash, getPubKeyHash()));
}
代码示例来源:origin: greenaddress/GreenBits
/**
* Returns true if this script is P2SH wrapping P2WPKH for provided key.
* @param pubKey
* @return
*/
public boolean isSentToP2WPKHP2SH(ECKey pubKey) {
byte[] scriptHash = Utils.sha256hash160(ScriptBuilder.createP2WPKHOutputScript(pubKey).getProgram());
return (isPayToScriptHash() && Arrays.equals(scriptHash, getPubKeyHash()));
}
代码示例来源:origin: fr.acinq/bitcoinj-core
@Override
protected void verifyContract(final Transaction contract) {
super.verifyContract(contract);
// Check contract matches P2SH hash
byte[] expected = getContractScript().getPubKeyHash();
byte[] actual = Utils.sha256hash160(createP2SHRedeemScript().getProgram());
if (!Arrays.equals(actual, expected)) {
throw new VerificationException(
"P2SH hash didn't match required contract - contract should be a CLTV micropayment channel to client and server in that order.");
}
}
代码示例来源:origin: cash.bitcoinj/bitcoinj-core
@Override
protected void verifyContract(final Transaction contract) {
super.verifyContract(contract);
// Check contract matches P2SH hash
byte[] expected = getContractScript().getPubKeyHash();
byte[] actual = Utils.sha256hash160(createP2SHRedeemScript().getProgram());
if (!Arrays.equals(actual, expected)) {
throw new VerificationException(
"P2SH hash didn't match required contract - contract should be a CLTV micropayment channel to client and server in that order.");
}
}
代码示例来源:origin: greenaddress/GreenBits
@Override
protected void verifyContract(final Transaction contract) {
super.verifyContract(contract);
// Check contract matches P2SH hash
byte[] expected = getContractScript().getPubKeyHash();
byte[] actual = Utils.sha256hash160(createP2SHRedeemScript().getProgram());
if (!Arrays.equals(actual, expected)) {
throw new VerificationException(
"P2SH hash didn't match required contract - contract should be a CLTV micropayment channel to client and server in that order.");
}
}
代码示例来源:origin: greenaddress/GreenBits
@Test
public void testScriptSig() throws Exception {
byte[] sigProgBytes = HEX.decode(sigProg);
Script script = new Script(sigProgBytes);
// Test we can extract the from address.
byte[] hash160 = Utils.sha256hash160(script.getPubKey());
Address a = new Address(PARAMS, hash160);
assertEquals("mkFQohBpy2HDXrCwyMrYL5RtfrmeiuuPY2", a.toString());
}
内容来源于网络,如有侵权,请联系作者删除!