script/address: fix addr checking for nested p2sh inputs.

This commit is contained in:
Christopher Jeffrey 2017-12-20 09:50:17 -08:00
parent 2054524fd7
commit 03ddc79dfc
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
2 changed files with 8 additions and 4 deletions

View File

@ -210,20 +210,24 @@ class Input {
if (coin)
return coin.getAddress();
if (this.script.code.length > 0)
return this.script.getInputAddress();
if (this.witness.items.length > 0)
return this.witness.getInputAddress();
return this.script.getInputAddress();
return null;
}
/**
* Get the address hash.
* @param {Coin?} coin
* @param {String?} enc
* @returns {Hash} hash
*/
getHash(enc) {
const addr = this.getAddress();
getHash(coin, enc) {
const addr = this.getAddress(coin);
if (!addr)
return null;

View File

@ -2337,7 +2337,7 @@ class Script {
*/
isScripthashInput() {
if (this.code.length < 2)
if (this.code.length < 1)
return false;
// Grab the raw redeem script.