@ -98,6 +98,24 @@ describe('Script', function() {
} )
} )
describe ( 'pay-to-pubKeyHash' , function ( ) {
it ( 'matches the test data' , function ( ) {
var address = Address . fromBase58Check ( '19E6FV3m3kEPoJD5Jz6dGKdKwTVvjsWUvu' )
var script = Script . createPubKeyHashScriptPubKey ( address . hash )
assert . equal ( script . toHex ( ) , pubKeyScriptPubKey )
} )
} )
describe ( 'pay-to-scriptHash' , function ( ) {
it ( 'matches the test data' , function ( ) {
var hash = new Buffer ( 'e8c300c87986efa84c37c0519929019ef86eb5b4' , 'hex' )
var script = Script . createP2SHScriptPubKey ( hash )
assert . equal ( script . toHex ( ) , p2shScriptPubKey )
} )
} )
describe ( 'getToAddress' , function ( ) {
it ( 'works for p2sh type output' , function ( ) {
var script = Script . fromHex ( p2shScriptPubKey )
@ -129,7 +147,7 @@ describe('Script', function() {
} )
it ( 'should create valid redeemScript' , function ( ) {
var redeemScript = Script . createMultisigOutput Script ( 2 , pubKeys )
var redeemScript = Script . createMultisigScriptPubKey ( 2 , pubKeys )
var hash160 = crypto . hash160 ( redeemScript . buffer )
var multisigAddress = new Address ( hash160 , networks . bitcoin . scriptHash )
@ -150,7 +168,7 @@ describe('Script', function() {
var expected = '0047304402207515cf147d201f411092e6be5a64a6006f9308fad7b2a8fdaab22cd86ce764c202200974b8aca7bf51dbf54150d3884e1ae04f675637b926ec33bf75939446f6ca2801483045022100ef253c1faa39e65115872519e5f0a33bbecf430c0f35cf562beabbad4da24d8d02201742be8ee49812a73adea3007c9641ce6725c32cd44ddb8e3a3af460015d14050147522102359c6e3f04cefbf089cf1d6670dc47c3fb4df68e2bad1fa5a369f9ce4b42bbd1210395a9d84d47d524548f79f435758c01faec5da2b7e551d3b8c995b7e06326ae4a52ae'
it ( 'should create a valid P2SH multisig scriptSig' , function ( ) {
var redeemScript = Script . createMultisigOutput Script ( 2 , pubKeys )
var redeemScript = Script . createMultisigScriptPubKey ( 2 , pubKeys )
var actual = Script . createP2SHMultisigScriptSig ( signatures , redeemScript )
assert . equal ( b2h ( actual . buffer ) , expected )