File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
modules/utxo-core/src/bip322 Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 11import { Hash } from 'fast-sha256' ;
22import { Psbt , Transaction , bitgo , networks } from '@bitgo/utxo-lib' ;
33
4+ import { isTaprootChain } from './utils' ;
5+
46export const BIP322_TAG = 'BIP0322-signed-message' ;
57
68/**
@@ -74,8 +76,7 @@ export function buildToSpendTransactionFromChainAndIndex(
7476 message : string | Buffer ,
7577 tag = BIP322_TAG
7678) : Transaction < bigint > {
77- const taprootChains = [ ...bitgo . chainCodesP2tr , ...bitgo . chainCodesP2trMusig2 ] ;
78- if ( taprootChains . some ( ( tc ) => tc === chain ) ) {
79+ if ( isTaprootChain ( chain ) ) {
7980 throw new Error ( 'BIP322 is not supported for Taproot script types.' ) ;
8081 }
8182
Original file line number Diff line number Diff line change @@ -28,3 +28,8 @@ export function getBip322ProofInputIndex(psbt: utxolib.Psbt): number | undefined
2828export function psbtIsBip322Proof ( psbt : utxolib . Psbt ) : boolean {
2929 return getBip322ProofInputIndex ( psbt ) !== undefined ;
3030}
31+
32+ export function isTaprootChain ( chain : utxolib . bitgo . ChainCode ) : boolean {
33+ const taprootChains = [ ...utxolib . bitgo . chainCodesP2tr , ...utxolib . bitgo . chainCodesP2trMusig2 ] ;
34+ return taprootChains . some ( ( tc ) => tc === chain ) ;
35+ }
You can’t perform that action at this time.
0 commit comments