fanatid / script2addresses

Transform bitcoin script to bitcoin addresses
MIT License
4 stars 2 forks source link

script2addresses

NPM Package Build Status Coverage Status js-standard-style Dependency status

Installation

npm install script2addresses

Script type and addresses

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

API


script2addresses

Arguments:

Returns an object with the following keys:

Example

var script2addresses = require('script2addresses')

// OP_2 032069e003dcc548bc7de5e2623a3f3716873cd08764f1ab9e16fc1ca69bee6aa5 0386acd4c6ffd015e71c0e3f535c3b6e70a777908cc31695de660846c87cf88ef3 OP_2 OP_CHECKMULTISIG'
var script = '5221032069e003dcc548bc7de5e2623a3f3716873cd08764f1ab9e16fc1ca69bee6aa5210386acd4c6ffd015e71c0e3f535c3b6e70a777908cc31695de660846c87cf88ef352ae'
console.log(script2addresses(script))
// {
//   type: 'multisig',
//   addresses: [
//     '17FpX7QDJTpUyd6C7Rk9CywBKs5CyAznvd',
//     '16kUTyxJhwcX1zehx4EY7j2ovHs7U35nyq'
//   ]
// }

License

This software is licensed under the MIT License.