@@ -4,6 +4,7 @@ import { Descriptor } from '@bitgo/wasm-miniscript';
44
55import { createMultiSigDescriptor } from '../../src/descriptor' ;
66import { finalizePsbt , getFixture , updateInputWithDescriptor } from './utils' ;
7+ import { decodeTimelock } from '../../src' ;
78
89describe ( 'descriptor' , function ( ) {
910 const baseFixturePath = 'test/fixtures/descriptor/' ;
@@ -114,4 +115,36 @@ describe('descriptor', function () {
114115 runTestForParams ( 'sh' , 2 , [ key1 , key2 ] ) ;
115116 runTestForParams ( 'sh-wsh' , 2 , [ key1 , key2 ] ) ;
116117 runTestForParams ( 'sh' , 3 , [ key1 , key2 , key3 ] ) ;
118+
119+ it ( 'should recreate the script used in testnet staking transaction' , function ( ) {
120+ // Source: https://mempool.space/testnet/address/2MxTi2EhHKgdJFKRTBttVGGxir9ZzjmKCXw
121+ // 2 of 2 multisig
122+ const timelock = 'fce4cb66' ;
123+ const pubkey1 = '03ecb6d4b7f5d56962e547fc52dd588359f5729c0ba856d6978b84723895a16691' ;
124+ const pubkey2 = '024aaea25d82b1db2be030a05b641d6302e48ed652b1ca9cb08a67267fcbb56747' ;
125+ const redeemScriptASM = [
126+ 'OP_PUSHBYTES_4' ,
127+ timelock ,
128+ 'OP_CLTV' ,
129+ 'OP_DROP' ,
130+ 'OP_PUSHNUM_2' ,
131+ 'OP_PUSHBYTES_33' ,
132+ pubkey1 ,
133+ 'OP_PUSHBYTES_33' ,
134+ pubkey2 ,
135+ 'OP_PUSHNUM_2' ,
136+ 'OP_CHECKMULTISIG' ,
137+ ] . join ( ' ' ) ;
138+
139+ const decodedTimelock = decodeTimelock ( Buffer . from ( timelock , 'hex' ) ) ;
140+ const descriptor = createMultiSigDescriptor (
141+ 'sh' ,
142+ decodedTimelock ,
143+ 2 ,
144+ [ Buffer . from ( pubkey1 , 'hex' ) , Buffer . from ( pubkey2 , 'hex' ) ] ,
145+ false
146+ ) ;
147+ const descriptorASM = Descriptor . fromString ( descriptor , 'definite' ) . toAsmString ( ) ;
148+ assert . deepStrictEqual ( redeemScriptASM , descriptorASM ) ;
149+ } ) ;
117150} ) ;
0 commit comments