diff options
author | Ian Coleman <ian@iancoleman.io> | 2019-12-17 11:44:54 +1100 |
---|---|---|
committer | Ian Coleman <ian@iancoleman.io> | 2019-12-17 11:46:07 +1100 |
commit | f7e9fdf002e7355a122a86a8407b470b56bf3f59 (patch) | |
tree | caaa9e0580d04280b40410b76feb3e0e7a7fcc91 /src | |
parent | 5c203fab6ac25fc76e2b805b7709d9b06ccdd995 (diff) | |
download | BIP39-f7e9fdf002e7355a122a86a8407b470b56bf3f59.tar.gz BIP39-f7e9fdf002e7355a122a86a8407b470b56bf3f59.tar.zst BIP39-f7e9fdf002e7355a122a86a8407b470b56bf3f59.zip |
Generate addresses for P2WSH and P2WSH-P2SH
Diffstat (limited to 'src')
-rw-r--r-- | src/index.html | 4 | ||||
-rw-r--r-- | src/js/index.js | 15 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/index.html b/src/index.html index 61fe022..64c25f4 100644 --- a/src/index.html +++ b/src/index.html | |||
@@ -509,8 +509,8 @@ | |||
509 | <select class="form-control bip141-semantics"> | 509 | <select class="form-control bip141-semantics"> |
510 | <option value="p2wpkh">P2WPKH</option> | 510 | <option value="p2wpkh">P2WPKH</option> |
511 | <option value="p2wpkh-p2sh" selected>P2WPKH nested in P2SH</option> | 511 | <option value="p2wpkh-p2sh" selected>P2WPKH nested in P2SH</option> |
512 | <option value="p2wsh">P2WSH</option> | 512 | <option value="p2wsh">P2WSH (1-of-1 multisig)</option> |
513 | <option value="p2wsh-p2sh">P2WSH nested in P2SH</option> | 513 | <option value="p2wsh-p2sh">P2WSH nested in P2SH (1-of-1 multisig)</option> |
514 | </select> | 514 | </select> |
515 | </div> | 515 | </div> |
516 | </div> | 516 | </div> |
diff --git a/src/js/index.js b/src/js/index.js index db47412..5fb0c47 100644 --- a/src/js/index.js +++ b/src/js/index.js | |||
@@ -1152,12 +1152,19 @@ | |||
1152 | address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network) | 1152 | address = bitcoinjs.bitcoin.address.fromOutputScript(scriptpubkey, network) |
1153 | } | 1153 | } |
1154 | else if (isP2wsh) { | 1154 | else if (isP2wsh) { |
1155 | // TODO | 1155 | // https://github.com/bitcoinjs/bitcoinjs-lib/blob/v3.3.2/test/integration/addresses.js#L71 |
1156 | address = ""; | 1156 | // This is a 1-of-1 |
1157 | var witnessScript = bitcoinjs.bitcoin.script.multisig.output.encode(1, [key.getPublicKeyBuffer()]); | ||
1158 | var scriptPubKey = bitcoinjs.bitcoin.script.witnessScriptHash.output.encode(bitcoinjs.bitcoin.crypto.sha256(witnessScript)); | ||
1159 | address = bitcoinjs.bitcoin.address.fromOutputScript(scriptPubKey, network); | ||
1157 | } | 1160 | } |
1158 | else if (isP2wshInP2sh) { | 1161 | else if (isP2wshInP2sh) { |
1159 | // TODO | 1162 | // https://github.com/bitcoinjs/bitcoinjs-lib/blob/v3.3.2/test/integration/transactions.js#L183 |
1160 | address = ""; | 1163 | // This is a 1-of-1 |
1164 | var witnessScript = bitcoinjs.bitcoin.script.multisig.output.encode(1, [key.getPublicKeyBuffer()]); | ||
1165 | var redeemScript = bitcoinjs.bitcoin.script.witnessScriptHash.output.encode(bitcoinjs.bitcoin.crypto.sha256(witnessScript)); | ||
1166 | var scriptPubKey = bitcoinjs.bitcoin.script.scriptHash.output.encode(bitcoinjs.bitcoin.crypto.hash160(redeemScript)); | ||
1167 | address = bitcoinjs.bitcoin.address.fromOutputScript(scriptPubKey, network) | ||
1161 | } | 1168 | } |
1162 | } | 1169 | } |
1163 | 1170 | ||