diff --git a/package.json b/package.json index d93703e..2516360 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bellhdw", - "version": "0.5.38", + "version": "0.5.42", "description": "Client-side Bitcoin JavaScript library", "main": "./src/index.js", "types": "./src/index.d.ts", @@ -37,12 +37,12 @@ ], "dependencies": { "@noble/hashes": "1.3.3", - "belcoinjs-lib": "0.1.1", - "bells-secp256k1": "0.1.0", - "belpair": "0.1.2", + "belcoinjs-lib": "0.1.2", + "bells-secp256k1": "0.1.1", + "belpair": "0.1.3", "nintondo-bip39": "1.0.0", "bn.js": "5.2.1", - "browser-hdkey": "0.1.8" + "browser-hdkey": "0.1.9" }, "devDependencies": { "@types/bn.js": "^5.1.1", diff --git a/ts_src/hd/private.ts b/ts_src/hd/private.ts index 01fa808..12bb7c2 100644 --- a/ts_src/hd/private.ts +++ b/ts_src/hd/private.ts @@ -162,7 +162,11 @@ class HDPrivateKey extends BaseWallet implements Keyring { inputs.forEach((input) => { account = this.findAccountByPk(input.publicKey); - if (this.addressType === AddressType.P2TR) { + if ( + (this.addressType === AddressType.P2TR || + this.addressType === AddressType.M44_P2TR) && + !input.disableTweakSigner + ) { const signer = tweakSigner(account, { network: this.network ?? networks.bellcoin, }); @@ -176,11 +180,19 @@ class HDPrivateKey extends BaseWallet implements Keyring { psbt.finalizeAllInputs(); } - signAllInputsInPsbt(psbt: Psbt, accountAddress: string) { + signAllInputsInPsbt( + psbt: Psbt, + accountAddress: string, + disableTweakSigner?: boolean + ) { const account = this.findAccount(accountAddress); psbt.data.inputs.forEach((input, idx) => { - if (this.addressType === AddressType.P2TR) { + if ( + (this.addressType === AddressType.P2TR || + this.addressType === AddressType.M44_P2TR) && + !disableTweakSigner + ) { const signer = tweakSigner(account, { network: this.network ?? networks.bellcoin, }); @@ -223,7 +235,11 @@ class HDPrivateKey extends BaseWallet implements Keyring { inputs.forEach((input) => { account = this.findAccountByPk(input.publicKey); - if (this.addressType === AddressType.P2TR) { + if ( + (this.addressType === AddressType.P2TR || + this.addressType === AddressType.M44_P2TR) && + !input.disableTweakSigner + ) { const signer = tweakSigner(account, { network: this.network ?? networks.bellcoin, }); diff --git a/ts_src/hd/simple.ts b/ts_src/hd/simple.ts index 7e8ac4b..166d2e7 100644 --- a/ts_src/hd/simple.ts +++ b/ts_src/hd/simple.ts @@ -149,7 +149,11 @@ class HDSimpleKey extends BaseWallet implements Keyring { inputs.forEach((input) => { const account = this.pair!; - if (this.addressType === AddressType.P2TR) { + if ( + (this.addressType === AddressType.P2TR || + this.addressType === AddressType.M44_P2TR) && + !input.disableTweakSigner + ) { const signer = tweakSigner(account, { network: this.network ?? networks.bellcoin, }); @@ -162,7 +166,11 @@ class HDSimpleKey extends BaseWallet implements Keyring { psbt.finalizeAllInputs(); } - signAllInputsInPsbt(psbt: Psbt, accountAddress: string) { + signAllInputsInPsbt( + psbt: Psbt, + accountAddress: string, + disableTweakSigner?: boolean + ) { this.initPair(); if (this.pair === undefined) throw new Error("Cannot sign all inputs since pair is undefined"); @@ -172,7 +180,11 @@ class HDSimpleKey extends BaseWallet implements Keyring { ); psbt.data.inputs.forEach((input, idx) => { - if (this.addressType === AddressType.P2TR) { + if ( + (this.addressType === AddressType.P2TR || + this.addressType === AddressType.M44_P2TR) && + !disableTweakSigner + ) { const signer = tweakSigner(this.pair!, { network: this.network ?? networks.bellcoin, }); @@ -214,7 +226,11 @@ class HDSimpleKey extends BaseWallet implements Keyring { if (this.pair === undefined) throw new Error("Cannot sign inputs since pair is undefined"); inputs.forEach((input) => { - if (this.addressType === AddressType.P2TR) { + if ( + (this.addressType === AddressType.P2TR || + this.addressType === AddressType.M44_P2TR) && + !input.disableTweakSigner + ) { const signer = tweakSigner(this.pair!, { network: this.network ?? networks.bellcoin, }); diff --git a/ts_src/hd/types.ts b/ts_src/hd/types.ts index 8c58c45..978cd73 100644 --- a/ts_src/hd/types.ts +++ b/ts_src/hd/types.ts @@ -52,6 +52,7 @@ export interface ToSignInput { index: number; publicKey: string; sighashTypes?: number[]; + disableTweakSigner?: boolean; } export enum AddressType { @@ -82,7 +83,8 @@ export type Keyring = { signTypedData(address: Hex, typedData: Record): string; signAllInputsInPsbt( psbt: Psbt, - accountAddress: string + accountAddress: string, + disableTweakSigner?: boolean ): { signatures: (string | undefined)[] }; signInputsWithoutFinalizing( psbt: Psbt,