@dynamic-labs-wallet/btc 0.0.0-pr534.1 → 0.0.0-pr534.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -563,6 +563,57 @@ initEccLib();
563
563
  };
564
564
  };
565
565
 
566
+ /**
567
+ * Calculates the Taproot tweak hash for BIP340 signing
568
+ * @param pubKey - The normalized public key (32-byte x-only for Taproot)
569
+ * @returns The tweak hash as a hex string (64 hex chars = 32 bytes)
570
+ */ const calculateTaprootTweak = (pubKey)=>{
571
+ const tweakHash = bitcoin__namespace.crypto.taggedHash('TapTweak', pubKey);
572
+ return Buffer.from(tweakHash).toString('hex');
573
+ };
574
+
575
+ /**
576
+ * Converts a signature to a Buffer format suitable for Taproot (BIP340/Schnorr)
577
+ * Taproot signatures are 64 bytes (r|s concatenated)
578
+ * @param signature - The signature from MPC (can be Uint8Array, Buffer, or EcdsaSignature object)
579
+ * @returns A Buffer containing the 64-byte Schnorr signature
580
+ */ const convertSignatureToTaprootBuffer = (signature)=>{
581
+ if (signature instanceof Uint8Array || Buffer.isBuffer(signature)) {
582
+ return Buffer.from(signature);
583
+ }
584
+ // ECDSA signature object - concat r and s for Schnorr
585
+ const r = signature.r;
586
+ const s = signature.s;
587
+ const rBuf = Buffer.isBuffer(r) ? r : Buffer.from(r);
588
+ const sBuf = Buffer.isBuffer(s) ? s : Buffer.from(s);
589
+ return Buffer.concat([
590
+ rBuf,
591
+ sBuf
592
+ ]);
593
+ };
594
+
595
+ /**
596
+ * Collects prevOutScripts and values from all PSBT inputs
597
+ * Required for Taproot (BIP-341) hashForWitnessV1 calculation
598
+ * @param psbt - The PSBT to collect input data from
599
+ * @returns An object containing arrays of prevOutScripts and values
600
+ * @throws Error if any input is missing witnessUtxo
601
+ */ const collectPSBTInputData = (psbt)=>{
602
+ const prevOutScripts = [];
603
+ const values = [];
604
+ psbt.data.inputs.forEach((input, index)=>{
605
+ if (!input.witnessUtxo) {
606
+ throw new Error(`Input ${index} missing witnessUtxo`);
607
+ }
608
+ prevOutScripts.push(Buffer.isBuffer(input.witnessUtxo.script) ? input.witnessUtxo.script : Buffer.from(input.witnessUtxo.script));
609
+ values.push(input.witnessUtxo.value);
610
+ });
611
+ return {
612
+ prevOutScripts,
613
+ values
614
+ };
615
+ };
616
+
566
617
  class DynamicBtcWalletClient extends browser.DynamicWalletClient {
567
618
  /**
568
619
  * Creates a Bitcoin wallet account
@@ -763,8 +814,7 @@ class DynamicBtcWalletClient extends browser.DynamicWalletClient {
763
814
  // Prepare tweak for Taproot in case of BIP340
764
815
  let tweak;
765
816
  if (addressType === browser.BitcoinAddressType.TAPROOT) {
766
- const tweakHash = bitcoin__namespace.crypto.taggedHash('TapTweak', pubKey);
767
- tweak = Buffer.from(tweakHash).toString('hex');
817
+ tweak = calculateTaprootTweak(pubKey);
768
818
  }
769
819
  // Build complete bitcoinConfig with addressType and tweak
770
820
  const completeBitcoinConfig = _extends({}, bitcoinConfig, {
@@ -949,48 +999,86 @@ class DynamicBtcWalletClient extends browser.DynamicWalletClient {
949
999
  throw new Error('Failed to derive public key');
950
1000
  }
951
1001
  const pubKey = normalizePublicKey(derivedPublicKey, addressType);
952
- // Iterate and sign inputs in parallel for better performance
953
- await Promise.all(psbt.data.inputs.map(async (input, i)=>{
954
- if (!input.witnessUtxo) {
955
- throw new Error(`Input ${i} missing witnessUtxo`);
956
- }
957
- const { script, value } = input.witnessUtxo;
958
- const p2pkh = bitcoin__namespace.payments.p2pkh({
959
- hash: script.slice(2),
960
- network: getBitcoinNetwork(network)
961
- });
962
- const scriptCode = p2pkh.output;
963
- if (!scriptCode) throw new Error('Failed to generate scriptCode');
964
- const tx = psbt.__CACHE.__TX;
965
- const hash = tx.hashForWitnessV0(i, scriptCode, value, bitcoin__namespace.Transaction.SIGHASH_ALL);
966
- const signature = await this.sign({
967
- message: new Uint8Array(hash),
968
- accountAddress: senderAddress,
969
- chainName: this.chainName,
970
- password,
971
- signedSessionId,
972
- mfaToken,
973
- isFormatted: true,
974
- context: context,
975
- bitcoinConfig,
976
- onError
1002
+ const tx = psbt.__CACHE.__TX;
1003
+ if (addressType === browser.BitcoinAddressType.TAPROOT) {
1004
+ const tweak = calculateTaprootTweak(pubKey);
1005
+ const completeBitcoinConfig = _extends({}, bitcoinConfig, {
1006
+ addressType: addressType,
1007
+ tweak
977
1008
  });
978
- const derSignature = convertSignatureToDER(signature);
979
- psbt.updateInput(i, {
980
- partialSig: [
981
- {
982
- pubkey: pubKey,
983
- signature: new Uint8Array(derSignature)
984
- }
985
- ]
1009
+ const { prevOutScripts, values } = collectPSBTInputData(psbt);
1010
+ await Promise.all(psbt.data.inputs.map(async (input, i)=>{
1011
+ if (!input.witnessUtxo) {
1012
+ throw new Error(`Input ${i} missing witnessUtxo`);
1013
+ }
1014
+ const hash = Buffer.from(tx.hashForWitnessV1(i, prevOutScripts, values, bitcoin__namespace.Transaction.SIGHASH_DEFAULT));
1015
+ const signature = await this.sign({
1016
+ message: new Uint8Array(hash),
1017
+ accountAddress: senderAddress,
1018
+ chainName: this.chainName,
1019
+ password,
1020
+ signedSessionId,
1021
+ mfaToken,
1022
+ isFormatted: true,
1023
+ context: context,
1024
+ bitcoinConfig: completeBitcoinConfig,
1025
+ onError
1026
+ });
1027
+ const sigBuffer = convertSignatureToTaprootBuffer(signature);
1028
+ psbt.updateInput(i, {
1029
+ tapKeySig: sigBuffer
1030
+ });
1031
+ }));
1032
+ } else {
1033
+ // Native SegWit (P2WPKH) or other ECDSA-based signing
1034
+ // Build bitcoinConfig without tweak (not needed for ECDSA)
1035
+ const completeBitcoinConfig = _extends({}, bitcoinConfig, {
1036
+ addressType: addressType
986
1037
  });
987
- }));
988
- psbt.finalizeAllInputs();
989
- const transactionHex = psbt.extractTransaction().toHex();
990
- this.logger.debug('[BTC Client] signTransaction - transactionHex', {
991
- transactionHex
1038
+ // Iterate and sign inputs in parallel for better performance
1039
+ await Promise.all(psbt.data.inputs.map(async (input, i)=>{
1040
+ if (!input.witnessUtxo) {
1041
+ throw new Error(`Input ${i} missing witnessUtxo`);
1042
+ }
1043
+ const { script, value } = input.witnessUtxo;
1044
+ // For Native SegWit (P2WPKH), use p2wpkh
1045
+ const p2wpkh = bitcoin__namespace.payments.p2wpkh({
1046
+ output: script,
1047
+ network: getBitcoinNetwork(network)
1048
+ });
1049
+ const scriptCode = p2wpkh.output || script;
1050
+ if (!scriptCode) throw new Error('Failed to generate scriptCode');
1051
+ const hash = tx.hashForWitnessV0(i, scriptCode, value, bitcoin__namespace.Transaction.SIGHASH_ALL);
1052
+ const signature = await this.sign({
1053
+ message: new Uint8Array(hash),
1054
+ accountAddress: senderAddress,
1055
+ chainName: this.chainName,
1056
+ password,
1057
+ signedSessionId,
1058
+ mfaToken,
1059
+ isFormatted: true,
1060
+ context: context,
1061
+ bitcoinConfig: completeBitcoinConfig,
1062
+ onError
1063
+ });
1064
+ const derSignature = convertSignatureToDER(signature);
1065
+ psbt.updateInput(i, {
1066
+ partialSig: [
1067
+ {
1068
+ pubkey: pubKey,
1069
+ signature: new Uint8Array(derSignature)
1070
+ }
1071
+ ]
1072
+ });
1073
+ }));
1074
+ }
1075
+ // Return signed PSBT in base64 format (not finalized)
1076
+ // This allows users to review, add additional signatures, or finalize themselves
1077
+ const signedPsbtBase64 = psbt.toBase64();
1078
+ this.logger.debug('[BTC Client] signTransaction - signedPsbtBase64', {
1079
+ signedPsbtBase64
992
1080
  });
993
- return transactionHex;
1081
+ return signedPsbtBase64;
994
1082
  } catch (error) {
995
1083
  if (onError) {
996
1084
  onError(error);
package/index.esm.js CHANGED
@@ -543,6 +543,57 @@ initEccLib();
543
543
  };
544
544
  };
545
545
 
546
+ /**
547
+ * Calculates the Taproot tweak hash for BIP340 signing
548
+ * @param pubKey - The normalized public key (32-byte x-only for Taproot)
549
+ * @returns The tweak hash as a hex string (64 hex chars = 32 bytes)
550
+ */ const calculateTaprootTweak = (pubKey)=>{
551
+ const tweakHash = bitcoin.crypto.taggedHash('TapTweak', pubKey);
552
+ return Buffer.from(tweakHash).toString('hex');
553
+ };
554
+
555
+ /**
556
+ * Converts a signature to a Buffer format suitable for Taproot (BIP340/Schnorr)
557
+ * Taproot signatures are 64 bytes (r|s concatenated)
558
+ * @param signature - The signature from MPC (can be Uint8Array, Buffer, or EcdsaSignature object)
559
+ * @returns A Buffer containing the 64-byte Schnorr signature
560
+ */ const convertSignatureToTaprootBuffer = (signature)=>{
561
+ if (signature instanceof Uint8Array || Buffer.isBuffer(signature)) {
562
+ return Buffer.from(signature);
563
+ }
564
+ // ECDSA signature object - concat r and s for Schnorr
565
+ const r = signature.r;
566
+ const s = signature.s;
567
+ const rBuf = Buffer.isBuffer(r) ? r : Buffer.from(r);
568
+ const sBuf = Buffer.isBuffer(s) ? s : Buffer.from(s);
569
+ return Buffer.concat([
570
+ rBuf,
571
+ sBuf
572
+ ]);
573
+ };
574
+
575
+ /**
576
+ * Collects prevOutScripts and values from all PSBT inputs
577
+ * Required for Taproot (BIP-341) hashForWitnessV1 calculation
578
+ * @param psbt - The PSBT to collect input data from
579
+ * @returns An object containing arrays of prevOutScripts and values
580
+ * @throws Error if any input is missing witnessUtxo
581
+ */ const collectPSBTInputData = (psbt)=>{
582
+ const prevOutScripts = [];
583
+ const values = [];
584
+ psbt.data.inputs.forEach((input, index)=>{
585
+ if (!input.witnessUtxo) {
586
+ throw new Error(`Input ${index} missing witnessUtxo`);
587
+ }
588
+ prevOutScripts.push(Buffer.isBuffer(input.witnessUtxo.script) ? input.witnessUtxo.script : Buffer.from(input.witnessUtxo.script));
589
+ values.push(input.witnessUtxo.value);
590
+ });
591
+ return {
592
+ prevOutScripts,
593
+ values
594
+ };
595
+ };
596
+
546
597
  class DynamicBtcWalletClient extends DynamicWalletClient {
547
598
  /**
548
599
  * Creates a Bitcoin wallet account
@@ -743,8 +794,7 @@ class DynamicBtcWalletClient extends DynamicWalletClient {
743
794
  // Prepare tweak for Taproot in case of BIP340
744
795
  let tweak;
745
796
  if (addressType === BitcoinAddressType.TAPROOT) {
746
- const tweakHash = bitcoin.crypto.taggedHash('TapTweak', pubKey);
747
- tweak = Buffer.from(tweakHash).toString('hex');
797
+ tweak = calculateTaprootTweak(pubKey);
748
798
  }
749
799
  // Build complete bitcoinConfig with addressType and tweak
750
800
  const completeBitcoinConfig = _extends({}, bitcoinConfig, {
@@ -929,48 +979,86 @@ class DynamicBtcWalletClient extends DynamicWalletClient {
929
979
  throw new Error('Failed to derive public key');
930
980
  }
931
981
  const pubKey = normalizePublicKey(derivedPublicKey, addressType);
932
- // Iterate and sign inputs in parallel for better performance
933
- await Promise.all(psbt.data.inputs.map(async (input, i)=>{
934
- if (!input.witnessUtxo) {
935
- throw new Error(`Input ${i} missing witnessUtxo`);
936
- }
937
- const { script, value } = input.witnessUtxo;
938
- const p2pkh = bitcoin.payments.p2pkh({
939
- hash: script.slice(2),
940
- network: getBitcoinNetwork(network)
941
- });
942
- const scriptCode = p2pkh.output;
943
- if (!scriptCode) throw new Error('Failed to generate scriptCode');
944
- const tx = psbt.__CACHE.__TX;
945
- const hash = tx.hashForWitnessV0(i, scriptCode, value, bitcoin.Transaction.SIGHASH_ALL);
946
- const signature = await this.sign({
947
- message: new Uint8Array(hash),
948
- accountAddress: senderAddress,
949
- chainName: this.chainName,
950
- password,
951
- signedSessionId,
952
- mfaToken,
953
- isFormatted: true,
954
- context: context,
955
- bitcoinConfig,
956
- onError
982
+ const tx = psbt.__CACHE.__TX;
983
+ if (addressType === BitcoinAddressType.TAPROOT) {
984
+ const tweak = calculateTaprootTweak(pubKey);
985
+ const completeBitcoinConfig = _extends({}, bitcoinConfig, {
986
+ addressType: addressType,
987
+ tweak
957
988
  });
958
- const derSignature = convertSignatureToDER(signature);
959
- psbt.updateInput(i, {
960
- partialSig: [
961
- {
962
- pubkey: pubKey,
963
- signature: new Uint8Array(derSignature)
964
- }
965
- ]
989
+ const { prevOutScripts, values } = collectPSBTInputData(psbt);
990
+ await Promise.all(psbt.data.inputs.map(async (input, i)=>{
991
+ if (!input.witnessUtxo) {
992
+ throw new Error(`Input ${i} missing witnessUtxo`);
993
+ }
994
+ const hash = Buffer.from(tx.hashForWitnessV1(i, prevOutScripts, values, bitcoin.Transaction.SIGHASH_DEFAULT));
995
+ const signature = await this.sign({
996
+ message: new Uint8Array(hash),
997
+ accountAddress: senderAddress,
998
+ chainName: this.chainName,
999
+ password,
1000
+ signedSessionId,
1001
+ mfaToken,
1002
+ isFormatted: true,
1003
+ context: context,
1004
+ bitcoinConfig: completeBitcoinConfig,
1005
+ onError
1006
+ });
1007
+ const sigBuffer = convertSignatureToTaprootBuffer(signature);
1008
+ psbt.updateInput(i, {
1009
+ tapKeySig: sigBuffer
1010
+ });
1011
+ }));
1012
+ } else {
1013
+ // Native SegWit (P2WPKH) or other ECDSA-based signing
1014
+ // Build bitcoinConfig without tweak (not needed for ECDSA)
1015
+ const completeBitcoinConfig = _extends({}, bitcoinConfig, {
1016
+ addressType: addressType
966
1017
  });
967
- }));
968
- psbt.finalizeAllInputs();
969
- const transactionHex = psbt.extractTransaction().toHex();
970
- this.logger.debug('[BTC Client] signTransaction - transactionHex', {
971
- transactionHex
1018
+ // Iterate and sign inputs in parallel for better performance
1019
+ await Promise.all(psbt.data.inputs.map(async (input, i)=>{
1020
+ if (!input.witnessUtxo) {
1021
+ throw new Error(`Input ${i} missing witnessUtxo`);
1022
+ }
1023
+ const { script, value } = input.witnessUtxo;
1024
+ // For Native SegWit (P2WPKH), use p2wpkh
1025
+ const p2wpkh = bitcoin.payments.p2wpkh({
1026
+ output: script,
1027
+ network: getBitcoinNetwork(network)
1028
+ });
1029
+ const scriptCode = p2wpkh.output || script;
1030
+ if (!scriptCode) throw new Error('Failed to generate scriptCode');
1031
+ const hash = tx.hashForWitnessV0(i, scriptCode, value, bitcoin.Transaction.SIGHASH_ALL);
1032
+ const signature = await this.sign({
1033
+ message: new Uint8Array(hash),
1034
+ accountAddress: senderAddress,
1035
+ chainName: this.chainName,
1036
+ password,
1037
+ signedSessionId,
1038
+ mfaToken,
1039
+ isFormatted: true,
1040
+ context: context,
1041
+ bitcoinConfig: completeBitcoinConfig,
1042
+ onError
1043
+ });
1044
+ const derSignature = convertSignatureToDER(signature);
1045
+ psbt.updateInput(i, {
1046
+ partialSig: [
1047
+ {
1048
+ pubkey: pubKey,
1049
+ signature: new Uint8Array(derSignature)
1050
+ }
1051
+ ]
1052
+ });
1053
+ }));
1054
+ }
1055
+ // Return signed PSBT in base64 format (not finalized)
1056
+ // This allows users to review, add additional signatures, or finalize themselves
1057
+ const signedPsbtBase64 = psbt.toBase64();
1058
+ this.logger.debug('[BTC Client] signTransaction - signedPsbtBase64', {
1059
+ signedPsbtBase64
972
1060
  });
973
- return transactionHex;
1061
+ return signedPsbtBase64;
974
1062
  } catch (error) {
975
1063
  if (onError) {
976
1064
  onError(error);
package/package.json CHANGED
@@ -1,18 +1,21 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/btc",
3
- "version": "0.0.0-pr534.1",
3
+ "version": "0.0.0-pr534.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
7
  "dependencies": {
8
8
  "@dynamic-labs/sdk-api-core": "^0.0.828",
9
- "@dynamic-labs-wallet/browser": "0.0.0-pr534.1",
9
+ "@dynamic-labs-wallet/browser": "0.0.0-pr534.2",
10
10
  "@bitcoinerlab/secp256k1": "^1.2.0",
11
11
  "bitcoinjs-lib": "^7.0.0",
12
12
  "bip322-js": "^3.0.0",
13
13
  "@noble/hashes": "1.7.1",
14
14
  "bs58": "^6.0.0"
15
15
  },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
16
19
  "nx": {
17
20
  "sourceRoot": "packages/btc/src",
18
21
  "projectType": "library",
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,K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A0CxC;;;;;;;;;;;;OAYG;IACG,eAAe,CAAC,EACpB,WAAW,EACX,aAAa,EACb,OAAO,EACP,QAAQ,EACR,eAAe,EACf,QAAQ,EACR,OAAO,EACP,OAAO,GACR,EAAE;QACD,WAAW,EAAE,MAAM,CAAC;QACpB,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,cAAc,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,eAAe,EAAE,MAAM,CAAC;QACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,kBAAkB,CAAC;QAC7B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;KAClC,GAAG,OAAO,CAAC,MAAM,CAAC;IA0LnB;;;;;;;;OAQG;IACG,iBAAiB,CAAC,EACtB,eAAe,EACf,MAAM,EACN,aAAa,EACb,OAAO,EACP,YAAuB,GACxB,EAAE;QACD,eAAe,EAAE,MAAM,CAAC;QACxB,MAAM,EAAE,MAAM,CAAC;QACf,aAAa,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,cAAc,CAAC;QACxB,YAAY,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,MAAM,CAAC;KAC3C,GAAG,OAAO,CAAC,MAAM,CAAC;IA6GnB;;;;;OAKG;YACW,QAAQ;IActB;;;OAGG;IACG,iBAAiB;CAOxB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Calculates the Taproot tweak hash for BIP340 signing
3
+ * @param pubKey - The normalized public key (32-byte x-only for Taproot)
4
+ * @returns The tweak hash as a hex string (64 hex chars = 32 bytes)
5
+ */
6
+ export declare const calculateTaprootTweak: (pubKey: Uint8Array | Buffer) => string;
7
+ //# sourceMappingURL=calculateTaprootTweak.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateTaprootTweak.d.ts","sourceRoot":"","sources":["../../../src/utils/calculateTaprootTweak/calculateTaprootTweak.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,WAAY,UAAU,GAAG,MAAM,KAAG,MAMnE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { calculateTaprootTweak } from './calculateTaprootTweak.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/calculateTaprootTweak/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { Psbt } from 'bitcoinjs-lib';
2
+ /**
3
+ * Collects prevOutScripts and values from all PSBT inputs
4
+ * Required for Taproot (BIP-341) hashForWitnessV1 calculation
5
+ * @param psbt - The PSBT to collect input data from
6
+ * @returns An object containing arrays of prevOutScripts and values
7
+ * @throws Error if any input is missing witnessUtxo
8
+ */
9
+ export declare const collectPSBTInputData: (psbt: Psbt) => {
10
+ prevOutScripts: Buffer[];
11
+ values: bigint[];
12
+ };
13
+ //# sourceMappingURL=collectPSBTInputData.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collectPSBTInputData.d.ts","sourceRoot":"","sources":["../../../src/utils/collectPSBTInputData/collectPSBTInputData.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,SAAU,IAAI,KAAG;IAChD,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,EAAE,MAAM,EAAE,CAAC;CAmBlB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { collectPSBTInputData } from './collectPSBTInputData.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/collectPSBTInputData/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { EcdsaSignature } from '@dynamic-labs-wallet/browser';
2
+ /**
3
+ * Converts a signature to a Buffer format suitable for Taproot (BIP340/Schnorr)
4
+ * Taproot signatures are 64 bytes (r|s concatenated)
5
+ * @param signature - The signature from MPC (can be Uint8Array, Buffer, or EcdsaSignature object)
6
+ * @returns A Buffer containing the 64-byte Schnorr signature
7
+ */
8
+ export declare const convertSignatureToTaprootBuffer: (signature: EcdsaSignature | Uint8Array | Buffer) => Buffer;
9
+ //# sourceMappingURL=convertSignatureToTaprootBuffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convertSignatureToTaprootBuffer.d.ts","sourceRoot":"","sources":["../../../src/utils/convertSignatureToTaprootBuffer/convertSignatureToTaprootBuffer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,cAC/B,cAAc,GAAG,UAAU,GAAG,MAAM,KAC9C,MAWF,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { convertSignatureToTaprootBuffer } from './convertSignatureToTaprootBuffer.js';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/convertSignatureToTaprootBuffer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC"}
@@ -9,4 +9,7 @@ export { getUTXOs } from './getUTXOs/index.js';
9
9
  export { selectUTXOs } from './selectUTXOs/index.js';
10
10
  export { getFeeRates } from './getFeeRates/index.js';
11
11
  export { getDefaultRpcUrl } from './getDefaultRpcUrl/index.js';
12
+ export { calculateTaprootTweak } from './calculateTaprootTweak/index.js';
13
+ export { convertSignatureToTaprootBuffer } from './convertSignatureToTaprootBuffer/index.js';
14
+ export { collectPSBTInputData } from './collectPSBTInputData/index.js';
12
15
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,sCAAsC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,gCAAgC,EAAE,MAAM,6CAA6C,CAAC;AAC/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAA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