1
1
import { bitcoin as BITCOIN_NETWORK } from '../networks' ;
2
2
import * as bscript from '../script' ;
3
3
import { liftX , tweakPublicKey , typeforce as typef } from '../types' ;
4
+ import { computeMastRoot } from '../merkle' ;
4
5
import { Payment , PaymentOpts } from './index' ;
5
6
import * as lazy from './lazy' ;
6
7
import { bech32m } from 'bech32' ;
@@ -27,6 +28,7 @@ export function p2tr(a: Payment, opts?: PaymentOpts): Payment {
27
28
pubkey : typef . maybe ( typef . BufferN ( 32 ) ) ,
28
29
signature : typef . maybe ( bscript . isCanonicalScriptSignature ) ,
29
30
witness : typef . maybe ( typef . arrayOf ( typef . Buffer ) ) ,
31
+ // scriptsTree: typef.maybe(typef.TaprootNode), // use merkel.isMast ?
30
32
} ,
31
33
a ,
32
34
) ;
@@ -58,7 +60,7 @@ export function p2tr(a: Payment, opts?: PaymentOpts): Payment {
58
60
59
61
lazy . prop ( o , 'hash' , ( ) => {
60
62
if ( a . hash ) return a . hash ;
61
- // todo: if (a.redeems?.length) compute from MAST root from redeems
63
+ if ( a . scriptsTree ) return computeMastRoot ( a . scriptsTree )
62
64
return null
63
65
} ) ;
64
66
lazy . prop ( o , 'output' , ( ) => {
0 commit comments