npm install script2addresses
pubkey
{PublicKey} OP_CHECKSIG
*This is only public key, but we can derive P2PKH address
pubkeyhash
OP_DUP OP_HASH160 {PublicKeyHash} OP_EQUALVERIFY OP_CHECKSIG
scripthash
OP_HASH160 {scriptHash} OP_EQUAL
multisig
m [PublicKeys ...] n OP_CHECKMULTISIG
*This is only public keys, but we can derive P2PKH addresses
script2addresses
Arguments:
script
- output script as string or buffernetwork
- network params or string (livenet, mainnet, testnet), mainnet by defaultstrict
- not allow pushdata opcodes in script, false by defaultReturns an object with the following keys:
type
- output script type: unknow, nulldata, pubkeyhash, scripthash, pubkey or multisigaddresses
- array of stringsvar script2addresses = require('script2addresses')
// OP_2 032069e003dcc548bc7de5e2623a3f3716873cd08764f1ab9e16fc1ca69bee6aa5 0386acd4c6ffd015e71c0e3f535c3b6e70a777908cc31695de660846c87cf88ef3 OP_2 OP_CHECKMULTISIG'
var script = '5221032069e003dcc548bc7de5e2623a3f3716873cd08764f1ab9e16fc1ca69bee6aa5210386acd4c6ffd015e71c0e3f535c3b6e70a777908cc31695de660846c87cf88ef352ae'
console.log(script2addresses(script))
// {
// type: 'multisig',
// addresses: [
// '17FpX7QDJTpUyd6C7Rk9CywBKs5CyAznvd',
// '16kUTyxJhwcX1zehx4EY7j2ovHs7U35nyq'
// ]
// }
This software is licensed under the MIT License.