@@ -307,23 +307,28 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
307
307
try {
308
308
payment = p2pkh ( { output, network } ) ;
309
309
isSegwit = false ;
310
+ isTaproot = false ;
310
311
} catch ( e ) { }
311
312
try {
312
313
payment = p2sh ( { output, network } ) ;
313
314
// It assumes that an addr(SH_ADDRESS) is always a add(SH_WPKH) address
314
315
isSegwit = true ;
316
+ isTaproot = false ;
315
317
} catch ( e ) { }
316
318
try {
317
319
payment = p2wpkh ( { output, network } ) ;
318
320
isSegwit = true ;
321
+ isTaproot = false ;
319
322
} catch ( e ) { }
320
323
try {
321
324
payment = p2wsh ( { output, network } ) ;
322
325
isSegwit = true ;
326
+ isTaproot = false ;
323
327
} catch ( e ) { }
324
328
try {
325
329
payment = p2tr ( { output, network } ) ;
326
330
isSegwit = true ;
331
+ isTaproot = true ;
327
332
} catch ( e ) { }
328
333
if ( ! payment ) {
329
334
throw new Error ( `Error: invalid address ${ matchedAddress } ` ) ;
@@ -332,6 +337,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
332
337
//pk(KEY)
333
338
else if ( canonicalExpression . match ( RE . rePkAnchored ) ) {
334
339
isSegwit = false ;
340
+ isTaproot = false ;
335
341
const keyExpression = canonicalExpression . match (
336
342
RE . reNonSegwitKeyExp
337
343
) ?. [ 0 ] ;
@@ -355,6 +361,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
355
361
//pkh(KEY) - legacy
356
362
else if ( canonicalExpression . match ( RE . rePkhAnchored ) ) {
357
363
isSegwit = false ;
364
+ isTaproot = false ;
358
365
const keyExpression = canonicalExpression . match (
359
366
RE . reNonSegwitKeyExp
360
367
) ?. [ 0 ] ;
@@ -377,6 +384,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
377
384
//sh(wpkh(KEY)) - nested segwit
378
385
else if ( canonicalExpression . match ( RE . reShWpkhAnchored ) ) {
379
386
isSegwit = true ;
387
+ isTaproot = false ;
380
388
const keyExpression = canonicalExpression . match ( RE . reSegwitKeyExp ) ?. [ 0 ] ;
381
389
if ( ! keyExpression )
382
390
throw new Error ( `Error: keyExpression could not me extracted` ) ;
@@ -402,6 +410,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
402
410
//wpkh(KEY) - native segwit
403
411
else if ( canonicalExpression . match ( RE . reWpkhAnchored ) ) {
404
412
isSegwit = true ;
413
+ isTaproot = false ;
405
414
const keyExpression = canonicalExpression . match ( RE . reSegwitKeyExp ) ?. [ 0 ] ;
406
415
if ( ! keyExpression )
407
416
throw new Error ( `Error: keyExpression could not me extracted` ) ;
@@ -422,6 +431,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
422
431
//sh(wsh(miniscript))
423
432
else if ( canonicalExpression . match ( RE . reShWshMiniscriptAnchored ) ) {
424
433
isSegwit = true ;
434
+ isTaproot = false ;
425
435
miniscript = canonicalExpression . match ( RE . reShWshMiniscriptAnchored ) ?. [ 1 ] ; //[1]-> whatever is found sh(wsh(->HERE<-))
426
436
if ( ! miniscript )
427
437
throw new Error ( `Error: could not get miniscript in ${ descriptor } ` ) ;
@@ -462,6 +472,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
462
472
//isSegwit false because we know it's a P2SH of a miniscript and not a
463
473
//P2SH that embeds a witness payment.
464
474
isSegwit = false ;
475
+ isTaproot = false ;
465
476
miniscript = canonicalExpression . match ( RE . reShMiniscriptAnchored ) ?. [ 1 ] ; //[1]-> whatever is found sh(->HERE<-)
466
477
if ( ! miniscript )
467
478
throw new Error ( `Error: could not get miniscript in ${ descriptor } ` ) ;
@@ -505,6 +516,7 @@ export function DescriptorsFactory(ecc: TinySecp256k1Interface) {
505
516
//wsh(miniscript)
506
517
else if ( canonicalExpression . match ( RE . reWshMiniscriptAnchored ) ) {
507
518
isSegwit = true ;
519
+ isTaproot = false ;
508
520
miniscript = canonicalExpression . match ( RE . reWshMiniscriptAnchored ) ?. [ 1 ] ; //[1]-> whatever is found wsh(->HERE<-)
509
521
if ( ! miniscript )
510
522
throw new Error ( `Error: could not get miniscript in ${ descriptor } ` ) ;
0 commit comments