From fd81fafdff502262870c28a1a48de5e9ea45e949 Mon Sep 17 00:00:00 2001 From: OutCast3k Date: Tue, 19 Jun 2018 15:45:21 +0000 Subject: [PATCH] segwit signing bug fix --- js/coin.js | 25 +++++++++++++++++-------- sha1sum | 4 ++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/js/coin.js b/js/coin.js index 4e01787..bf69d67 100644 --- a/js/coin.js +++ b/js/coin.js @@ -1549,19 +1549,28 @@ if(!witness_used.includes(y)){ var sw = coinjs.segwitAddress(this.witness[y][1]); var b32 = coinjs.bech32Address(this.witness[y][1]); - if(this.ins[i].script.chunks.length>0){ - if((sw['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0])) || (b32['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0]))){ - witness_order.push(this.witness[y]); - witness_used.push(y); - if(b32['redeemscript'] == Crypto.util.bytesToHex(this.ins[i].script.chunks[0])){ - this.ins[index].script = coinjs.script(); - } - break; + var rs = ''; + + if(this.ins[i].script.chunks.length>=1){ + rs = Crypto.util.bytesToHex(this.ins[i].script.chunks[0]); + } else if (this.ins[i].script.chunks.length==0){ + rs = b32['redeemscript']; + } + + if((sw['redeemscript'] == rs) || (b32['redeemscript'] == rs)){ + witness_order.push(this.witness[y]); + witness_used.push(y); + + // bech32, empty redeemscript + if(b32['redeemscript'] == rs){ + this.ins[index].script = coinjs.script(); } + break; } } } } + this.witness = witness_order; } } diff --git a/sha1sum b/sha1sum index 96c461b..c2551e0 100644 --- a/sha1sum +++ b/sha1sum @@ -1,9 +1,9 @@ ----- Version 1.4 2018.06.17 --- +---- Version 1.4 2018.06.19 --- 77e4519962e2f6a9fc93342137dbb31c33b76b04 ./js/aes.js 3a09a8fc0cfe828b57fc798d668234d0490ee1a6 ./js/bootstrap-datetimepicker.min.js 253711c6d825de55a8360552573be950da180614 ./js/bootstrap.min.js 988f99187ab356bc5d12b61572f463e1785c15c2 ./js/coinbin.js -776a3e2ae1e5835cf0c290987ac5343d8f57ad73 ./js/coin.js +8b4163122d907f9c363b9afd8809490f5ba202c8 ./js/coin.js 988565bc2cb402d63ed5c5fd7ff47c4278efc2c5 ./js/collapse.js 9ba5ede3d7f9d4c8fd623395f196adfdcf7e970f ./js/crypto-min.js f7c09f2f5a721371e7d478050119f7e2d58e3ef9 ./js/crypto-sha256-hmac.js