You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Get the hash of a base58 address or address-related object.
* @param {String|Address|Hash} data
* @param {String?} enc - Can be `"hex"` or `null`.
* @returns {Hash}
*/
staticgetHash(data,enc){
if(!data)
thrownewError('Object is not an address.');
lethash;
if(Buffer.isBuffer(data)){
if(data.length!==20&&data.length!==32)
thrownewError('Object is not an address.');
hash=data;
}elseif(datainstanceofAddress){
hash=data.hash;
}else{
thrownewError('Object is not an address.');
}
if(enc==='hex')
returnhash.toString('hex');
returnhash;
}
Since bitcoin/bitcoin#15846 "[POLICY] Make sending to future native witness outputs standard #15846" it's not entirely unreasonable to prepare for this.
$ bwallet-cli send bcrt1ypqyqsvwxy99 1.0
[error] (node) Object is not an address.
at Function.getHash (/Users/matthewzipkin/Desktop/work/bcoin/lib/primitives/address.js:811:15)
at Wallet.readPath (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/wallet.js:894:26)
at Wallet.syncOutputDepth (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/wallet.js:1660:31)
at Wallet._add (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/wallet.js:1910:34)
at async Wallet.add (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/wallet.js:1892:14)
at async WalletDB._addTX (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/walletdb.js:2166:11)
at async WalletDB.addTX (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/walletdb.js:2128:14)
at async Wallet._send (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/wallet.js:1355:5)
at async Wallet.send (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/wallet.js:1320:14)
at async Route.handler (/Users/matthewzipkin/Desktop/work/bcoin/lib/wallet/http.js:464:18)
[debug] (net) Connecting to 100.33.69.78:10000.
I think this could actually prevent the wallet from accepting an incoming TX if just one of the other outputs had a non-standard witness address.
pinheadmz
changed the title
Witness program data length is not always checked against witness program version
Address getHash requires data length of 20 or 32 only
Aug 13, 2020
So far witness v0 and proposed v1 program schemes define data lengths of either 20 or 32 bytes. However, future witness versions may be more flexible.
In particular,
Address.getHash()
always expects the program data to be 20 or 32 bytes.bcoin/lib/primitives/address.js
Lines 795 to 822 in 0551096
Since bitcoin/bitcoin#15846 "[POLICY] Make sending to future native witness outputs standard #15846" it's not entirely unreasonable to prepare for this.
Test case:
Bitcoin Core doesn't mind:
log:
The text was updated successfully, but these errors were encountered: