@btc-vision/transaction 1.1.7 → 1.1.9
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/browser/_version.d.ts +1 -1
- package/browser/index.js +1 -1
- package/browser/keypair/MessageSigner.d.ts +11 -0
- package/browser/opnet.d.ts +2 -1
- package/browser/utils/BufferHelper.d.ts +1 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/buffer/BinaryWriter.js +1 -1
- package/build/keypair/EcKeyPair.js +1 -1
- package/build/keypair/MessageSigner.d.ts +11 -0
- package/build/keypair/MessageSigner.js +41 -0
- package/build/opnet.d.ts +2 -1
- package/build/opnet.js +2 -1
- package/build/utils/BufferHelper.d.ts +1 -1
- package/build/utils/BufferHelper.js +5 -5
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/buffer/BinaryWriter.ts +1 -1
- package/src/keypair/EcKeyPair.ts +1 -1
- package/src/keypair/MessageSigner.ts +99 -0
- package/src/opnet.ts +2 -9
- package/src/utils/BufferHelper.ts +5 -6
- package/src/transaction/builders/UnwrapSegwitTransaction.ts.disabled +0 -371
- package/src/transaction/builders/UnwrapTransaction.ts.disabled +0 -503
- package/src/transaction/builders/WrapTransaction.ts.disabled +0 -338
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ECPairInterface } from 'ecpair';
|
|
2
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
3
|
+
declare class MessageSignerBase {
|
|
4
|
+
sha256(message: Buffer | Uint8Array): Buffer;
|
|
5
|
+
tweakAndSignMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string, network: Network): Uint8Array;
|
|
6
|
+
signMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string): Uint8Array;
|
|
7
|
+
verifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
|
|
8
|
+
tweakAndVerifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const MessageSigner: MessageSignerBase;
|
|
11
|
+
export {};
|
package/browser/opnet.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export * from './keypair/EcKeyPair.js';
|
|
|
13
13
|
export * from './keypair/Wallet.js';
|
|
14
14
|
export * from './keypair/interfaces/IWallet.js';
|
|
15
15
|
export * from './keypair/AddressVerificator.js';
|
|
16
|
+
export * from './keypair/MessageSigner.js';
|
|
16
17
|
export * from './metadata/ContractBaseMetadata.js';
|
|
18
|
+
export * from './network/ChainId.js';
|
|
17
19
|
export * from './signer/TweakedSigner.js';
|
|
18
20
|
export * from './transaction/TransactionFactory.js';
|
|
19
21
|
export * from './transaction/interfaces/ITransactionParameters.js';
|
|
@@ -26,7 +28,6 @@ export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
|
26
28
|
export * from './transaction/builders/DeploymentTransaction.js';
|
|
27
29
|
export * from './transaction/builders/CustomScriptTransaction.js';
|
|
28
30
|
export * from './transaction/builders/MultiSignTransaction.js';
|
|
29
|
-
export * from './network/ChainId.js';
|
|
30
31
|
export * from './utils/BitcoinUtils.js';
|
|
31
32
|
export * from './utxo/interfaces/IUTXO.js';
|
|
32
33
|
export * from './utxo/OPNetLimitedProvider.js';
|
|
@@ -6,6 +6,6 @@ export declare class BufferHelper {
|
|
|
6
6
|
static hexToUint8Array(input: string): Uint8Array;
|
|
7
7
|
static pointerToUint8Array(pointer: MemorySlotPointer): Uint8Array;
|
|
8
8
|
static uint8ArrayToPointer(input: Uint8Array): MemorySlotPointer;
|
|
9
|
-
static valueToUint8Array(value: bigint): Uint8Array;
|
|
9
|
+
static valueToUint8Array(value: bigint, length?: number): Uint8Array;
|
|
10
10
|
static uint8ArrayToValue(input: Uint8Array): bigint;
|
|
11
11
|
}
|
package/build/_version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "1.1.
|
|
1
|
+
export declare const version = "1.1.9";
|
package/build/_version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.1.
|
|
1
|
+
export const version = '1.1.9';
|
|
@@ -58,7 +58,7 @@ export class BinaryWriter {
|
|
|
58
58
|
throw new Error('Value is too large.');
|
|
59
59
|
}
|
|
60
60
|
this.allocSafe(16);
|
|
61
|
-
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue);
|
|
61
|
+
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue, 16);
|
|
62
62
|
if (bytesToHex.byteLength !== 16) {
|
|
63
63
|
throw new Error(`Invalid u128 value: ${bigIntValue}`);
|
|
64
64
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
2
2
|
import bip32, { BIP32Factory } from 'bip32';
|
|
3
3
|
import { address, initEccLib, networks, payments } from '@btc-vision/bitcoin';
|
|
4
|
-
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
5
4
|
import { ECPairFactory } from 'ecpair';
|
|
6
5
|
import { CURVE, ProjectivePoint as Point } from '@noble/secp256k1';
|
|
7
6
|
import { taggedHash } from '@btc-vision/bitcoin/src/crypto.js';
|
|
7
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
8
8
|
initEccLib(ecc);
|
|
9
9
|
const BIP32factory = typeof bip32 === 'function' ? bip32 : BIP32Factory;
|
|
10
10
|
if (!BIP32factory) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ECPairInterface } from 'ecpair';
|
|
2
|
+
import { Network } from '@btc-vision/bitcoin';
|
|
3
|
+
declare class MessageSignerBase {
|
|
4
|
+
sha256(message: Buffer | Uint8Array): Buffer;
|
|
5
|
+
tweakAndSignMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string, network: Network): Uint8Array;
|
|
6
|
+
signMessage(keypair: ECPairInterface, message: Uint8Array | Buffer | string): Uint8Array;
|
|
7
|
+
verifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
|
|
8
|
+
tweakAndVerifySignature(publicKey: Uint8Array | Buffer, message: Uint8Array | Buffer | string, signature: Uint8Array | Buffer): boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const MessageSigner: MessageSignerBase;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
2
|
+
import { crypto } from '@btc-vision/bitcoin';
|
|
3
|
+
import { TweakedSigner } from '../signer/TweakedSigner.js';
|
|
4
|
+
import { EcKeyPair } from './EcKeyPair.js';
|
|
5
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
6
|
+
class MessageSignerBase {
|
|
7
|
+
sha256(message) {
|
|
8
|
+
return crypto.sha256(Buffer.from(message));
|
|
9
|
+
}
|
|
10
|
+
tweakAndSignMessage(keypair, message, network) {
|
|
11
|
+
const tweaked = TweakedSigner.tweakSigner(keypair, {
|
|
12
|
+
network,
|
|
13
|
+
});
|
|
14
|
+
return this.signMessage(tweaked, message);
|
|
15
|
+
}
|
|
16
|
+
signMessage(keypair, message) {
|
|
17
|
+
if (typeof message === 'string') {
|
|
18
|
+
message = Buffer.from(message, 'utf-8');
|
|
19
|
+
}
|
|
20
|
+
if (!keypair.privateKey) {
|
|
21
|
+
throw new Error('Private key not found in keypair.');
|
|
22
|
+
}
|
|
23
|
+
const hashedMessage = this.sha256(message);
|
|
24
|
+
return ecc.signSchnorr(hashedMessage, keypair.privateKey);
|
|
25
|
+
}
|
|
26
|
+
verifySignature(publicKey, message, signature) {
|
|
27
|
+
if (typeof message === 'string') {
|
|
28
|
+
message = Buffer.from(message, 'utf-8');
|
|
29
|
+
}
|
|
30
|
+
if (signature.length !== 64) {
|
|
31
|
+
throw new Error('Invalid signature length.');
|
|
32
|
+
}
|
|
33
|
+
const hashedMessage = this.sha256(message);
|
|
34
|
+
return ecc.verifySchnorr(hashedMessage, toXOnly(Buffer.from(publicKey)), signature);
|
|
35
|
+
}
|
|
36
|
+
tweakAndVerifySignature(publicKey, message, signature) {
|
|
37
|
+
const tweakedPublicKey = EcKeyPair.tweakPublicKey(Buffer.from(publicKey));
|
|
38
|
+
return this.verifySignature(tweakedPublicKey, message, signature);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export const MessageSigner = new MessageSignerBase();
|
package/build/opnet.d.ts
CHANGED
|
@@ -13,7 +13,9 @@ export * from './keypair/EcKeyPair.js';
|
|
|
13
13
|
export * from './keypair/Wallet.js';
|
|
14
14
|
export * from './keypair/interfaces/IWallet.js';
|
|
15
15
|
export * from './keypair/AddressVerificator.js';
|
|
16
|
+
export * from './keypair/MessageSigner.js';
|
|
16
17
|
export * from './metadata/ContractBaseMetadata.js';
|
|
18
|
+
export * from './network/ChainId.js';
|
|
17
19
|
export * from './signer/TweakedSigner.js';
|
|
18
20
|
export * from './transaction/TransactionFactory.js';
|
|
19
21
|
export * from './transaction/interfaces/ITransactionParameters.js';
|
|
@@ -26,7 +28,6 @@ export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
|
26
28
|
export * from './transaction/builders/DeploymentTransaction.js';
|
|
27
29
|
export * from './transaction/builders/CustomScriptTransaction.js';
|
|
28
30
|
export * from './transaction/builders/MultiSignTransaction.js';
|
|
29
|
-
export * from './network/ChainId.js';
|
|
30
31
|
export * from './utils/BitcoinUtils.js';
|
|
31
32
|
export * from './utxo/interfaces/IUTXO.js';
|
|
32
33
|
export * from './utxo/OPNetLimitedProvider.js';
|
package/build/opnet.js
CHANGED
|
@@ -13,7 +13,9 @@ export * from './keypair/EcKeyPair.js';
|
|
|
13
13
|
export * from './keypair/Wallet.js';
|
|
14
14
|
export * from './keypair/interfaces/IWallet.js';
|
|
15
15
|
export * from './keypair/AddressVerificator.js';
|
|
16
|
+
export * from './keypair/MessageSigner.js';
|
|
16
17
|
export * from './metadata/ContractBaseMetadata.js';
|
|
18
|
+
export * from './network/ChainId.js';
|
|
17
19
|
export * from './signer/TweakedSigner.js';
|
|
18
20
|
export * from './transaction/TransactionFactory.js';
|
|
19
21
|
export * from './transaction/interfaces/ITransactionParameters.js';
|
|
@@ -26,7 +28,6 @@ export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
|
26
28
|
export * from './transaction/builders/DeploymentTransaction.js';
|
|
27
29
|
export * from './transaction/builders/CustomScriptTransaction.js';
|
|
28
30
|
export * from './transaction/builders/MultiSignTransaction.js';
|
|
29
|
-
export * from './network/ChainId.js';
|
|
30
31
|
export * from './utils/BitcoinUtils.js';
|
|
31
32
|
export * from './utxo/interfaces/IUTXO.js';
|
|
32
33
|
export * from './utxo/OPNetLimitedProvider.js';
|
|
@@ -6,6 +6,6 @@ export declare class BufferHelper {
|
|
|
6
6
|
static hexToUint8Array(input: string): Uint8Array;
|
|
7
7
|
static pointerToUint8Array(pointer: MemorySlotPointer): Uint8Array;
|
|
8
8
|
static uint8ArrayToPointer(input: Uint8Array): MemorySlotPointer;
|
|
9
|
-
static valueToUint8Array(value: bigint): Uint8Array;
|
|
9
|
+
static valueToUint8Array(value: bigint, length?: number): Uint8Array;
|
|
10
10
|
static uint8ArrayToValue(input: Uint8Array): bigint;
|
|
11
11
|
}
|
|
@@ -21,9 +21,9 @@ export class BufferHelper {
|
|
|
21
21
|
if (input.length % 2 !== 0) {
|
|
22
22
|
input = '0' + input;
|
|
23
23
|
}
|
|
24
|
-
const
|
|
25
|
-
const buffer = new Uint8Array(
|
|
26
|
-
for (let i = 0; i <
|
|
24
|
+
const lengthS = input.length / 2;
|
|
25
|
+
const buffer = new Uint8Array(lengthS);
|
|
26
|
+
for (let i = 0; i < lengthS; i++) {
|
|
27
27
|
buffer[i] = parseInt(input.substring(i * 2, i * 2 + 2), 16);
|
|
28
28
|
}
|
|
29
29
|
return buffer;
|
|
@@ -36,8 +36,8 @@ export class BufferHelper {
|
|
|
36
36
|
const hex = BufferHelper.uint8ArrayToHex(input);
|
|
37
37
|
return BigInt('0x' + hex);
|
|
38
38
|
}
|
|
39
|
-
static valueToUint8Array(value) {
|
|
40
|
-
const valueHex = value.toString(16).padStart(
|
|
39
|
+
static valueToUint8Array(value, length = 32) {
|
|
40
|
+
const valueHex = value.toString(16).padStart(length * 2, '0');
|
|
41
41
|
return BufferHelper.hexToUint8Array(valueHex);
|
|
42
42
|
}
|
|
43
43
|
static uint8ArrayToValue(input) {
|
package/package.json
CHANGED
package/src/_version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '1.1.
|
|
1
|
+
export const version = '1.1.9';
|
|
@@ -78,7 +78,7 @@ export class BinaryWriter {
|
|
|
78
78
|
|
|
79
79
|
this.allocSafe(16);
|
|
80
80
|
|
|
81
|
-
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue);
|
|
81
|
+
const bytesToHex = BufferHelper.valueToUint8Array(bigIntValue, 16);
|
|
82
82
|
if (bytesToHex.byteLength !== 16) {
|
|
83
83
|
throw new Error(`Invalid u128 value: ${bigIntValue}`);
|
|
84
84
|
}
|
package/src/keypair/EcKeyPair.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
2
2
|
import bip32, { BIP32API, BIP32Factory, BIP32Interface } from 'bip32';
|
|
3
3
|
import { address, initEccLib, Network, networks, payments, Signer } from '@btc-vision/bitcoin';
|
|
4
|
-
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
5
4
|
import { ECPairAPI, ECPairFactory, ECPairInterface } from 'ecpair';
|
|
6
5
|
import { IWallet } from './interfaces/IWallet.js';
|
|
7
6
|
import { CURVE, ProjectivePoint as Point } from '@noble/secp256k1';
|
|
8
7
|
import { taggedHash } from '@btc-vision/bitcoin/src/crypto.js';
|
|
8
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
9
9
|
|
|
10
10
|
initEccLib(ecc);
|
|
11
11
|
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { ECPairInterface } from 'ecpair';
|
|
2
|
+
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
3
|
+
import { crypto, Network } from '@btc-vision/bitcoin';
|
|
4
|
+
import { TweakedSigner } from '../signer/TweakedSigner.js';
|
|
5
|
+
import { EcKeyPair } from './EcKeyPair.js';
|
|
6
|
+
import { toXOnly } from '@btc-vision/bitcoin/src/psbt/bip371.js';
|
|
7
|
+
|
|
8
|
+
class MessageSignerBase {
|
|
9
|
+
public sha256(message: Buffer | Uint8Array): Buffer {
|
|
10
|
+
return crypto.sha256(Buffer.from(message));
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Tweak the keypair and sign a message.
|
|
15
|
+
* @param {ECPairInterface} keypair - The keypair to sign the message with. Must contain a private key.
|
|
16
|
+
* @param {Uint8Array | Buffer | string} message - The message to sign.
|
|
17
|
+
* @param {Network} network - The network to sign the message for.
|
|
18
|
+
* @returns The Schnorr signature.
|
|
19
|
+
*/
|
|
20
|
+
public tweakAndSignMessage(
|
|
21
|
+
keypair: ECPairInterface,
|
|
22
|
+
message: Uint8Array | Buffer | string,
|
|
23
|
+
network: Network,
|
|
24
|
+
): Uint8Array {
|
|
25
|
+
const tweaked = TweakedSigner.tweakSigner(keypair, {
|
|
26
|
+
network,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return this.signMessage(tweaked, message);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Signs a message using the provided keypair.
|
|
34
|
+
* @param {ECPairInterface} keypair - The keypair to sign the message with. Must contain a private key.
|
|
35
|
+
* @param {Uint8Array | Buffer | string} message - The message to sign.
|
|
36
|
+
* @returns The Schnorr signature.
|
|
37
|
+
* @throws Error if the private key is missing or invalid.
|
|
38
|
+
*/
|
|
39
|
+
public signMessage(
|
|
40
|
+
keypair: ECPairInterface,
|
|
41
|
+
message: Uint8Array | Buffer | string,
|
|
42
|
+
): Uint8Array {
|
|
43
|
+
if (typeof message === 'string') {
|
|
44
|
+
message = Buffer.from(message, 'utf-8');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (!keypair.privateKey) {
|
|
48
|
+
throw new Error('Private key not found in keypair.');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const hashedMessage = this.sha256(message);
|
|
52
|
+
return ecc.signSchnorr(hashedMessage, keypair.privateKey);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Verifies a Schnorr signature.
|
|
57
|
+
* @param {Uint8Array | Buffer} publicKey - The public key as a Uint8Array or Buffer.
|
|
58
|
+
* @param {Uint8Array | Buffer | string} message - The message to verify.
|
|
59
|
+
* @param {Uint8Array | Buffer} signature - The signature to verify.
|
|
60
|
+
* @returns True if the signature is valid, false otherwise.
|
|
61
|
+
* @throws Error if the signature length is invalid.
|
|
62
|
+
*/
|
|
63
|
+
public verifySignature(
|
|
64
|
+
publicKey: Uint8Array | Buffer,
|
|
65
|
+
message: Uint8Array | Buffer | string,
|
|
66
|
+
signature: Uint8Array | Buffer,
|
|
67
|
+
): boolean {
|
|
68
|
+
if (typeof message === 'string') {
|
|
69
|
+
message = Buffer.from(message, 'utf-8');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (signature.length !== 64) {
|
|
73
|
+
throw new Error('Invalid signature length.');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const hashedMessage = this.sha256(message);
|
|
77
|
+
return ecc.verifySchnorr(hashedMessage, toXOnly(Buffer.from(publicKey)), signature);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Tweak the public key and verify a signature.
|
|
82
|
+
* @param {Uint8Array | Buffer} publicKey - The public key as a Uint8Array or Buffer.
|
|
83
|
+
* @param {Uint8Array | Buffer | string} message - The message to verify.
|
|
84
|
+
* @param {Uint8Array | Buffer} signature - The signature to verify.
|
|
85
|
+
* @returns True if the signature is valid, false otherwise.
|
|
86
|
+
* @throws Error if the signature length is invalid.
|
|
87
|
+
*/
|
|
88
|
+
public tweakAndVerifySignature(
|
|
89
|
+
publicKey: Uint8Array | Buffer,
|
|
90
|
+
message: Uint8Array | Buffer | string,
|
|
91
|
+
signature: Uint8Array | Buffer,
|
|
92
|
+
): boolean {
|
|
93
|
+
const tweakedPublicKey = EcKeyPair.tweakPublicKey(Buffer.from(publicKey));
|
|
94
|
+
|
|
95
|
+
return this.verifySignature(tweakedPublicKey, message, signature);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const MessageSigner = new MessageSignerBase();
|
package/src/opnet.ts
CHANGED
|
@@ -21,10 +21,11 @@ export * from './keypair/EcKeyPair.js';
|
|
|
21
21
|
export * from './keypair/Wallet.js';
|
|
22
22
|
export * from './keypair/interfaces/IWallet.js';
|
|
23
23
|
export * from './keypair/AddressVerificator.js';
|
|
24
|
+
export * from './keypair/MessageSigner.js';
|
|
24
25
|
|
|
25
26
|
/** Metadata */
|
|
26
|
-
//export * from './metadata/contracts/wBTC.js';
|
|
27
27
|
export * from './metadata/ContractBaseMetadata.js';
|
|
28
|
+
export * from './network/ChainId.js';
|
|
28
29
|
|
|
29
30
|
/** Signer */
|
|
30
31
|
export * from './signer/TweakedSigner.js';
|
|
@@ -39,18 +40,11 @@ export * from './transaction/enums/TransactionType.js';
|
|
|
39
40
|
export * from './transaction/builders/InteractionTransaction.js';
|
|
40
41
|
export * from './transaction/builders/FundingTransaction.js';
|
|
41
42
|
export * from './transaction/builders/TransactionBuilder.js';
|
|
42
|
-
//export * from './transaction/builders/WrapTransaction.ts.disabled';
|
|
43
43
|
export * from './transaction/builders/SharedInteractionTransaction.js';
|
|
44
44
|
export * from './transaction/builders/DeploymentTransaction.js';
|
|
45
|
-
//export * from './transaction/builders/UnwrapTransaction.ts.disabled';
|
|
46
45
|
export * from './transaction/builders/CustomScriptTransaction.js';
|
|
47
46
|
export * from './transaction/builders/MultiSignTransaction.js';
|
|
48
47
|
|
|
49
|
-
/** wBTC */
|
|
50
|
-
//export * from '../wbtc_disabled/WrappedGenerationParameters.js';
|
|
51
|
-
//export * from '../wbtc_disabled/Generate.js';
|
|
52
|
-
export * from './network/ChainId.js';
|
|
53
|
-
|
|
54
48
|
/** Utils */
|
|
55
49
|
export * from './utils/BitcoinUtils.js';
|
|
56
50
|
|
|
@@ -67,7 +61,6 @@ export * from './utxo/interfaces/BroadcastResponse.js';
|
|
|
67
61
|
export * from './transaction/psbt/PSBTTypes.js';
|
|
68
62
|
|
|
69
63
|
export * from './transaction/shared/P2TR_MS.js';
|
|
70
|
-
//export * from '../wbtc_disabled/UnwrapGeneration.ts.disabled';
|
|
71
64
|
|
|
72
65
|
/** Consensus */
|
|
73
66
|
export * from './consensus/ConsensusConfig.js';
|
|
@@ -32,11 +32,10 @@ export class BufferHelper {
|
|
|
32
32
|
input = '0' + input; // Pad with a leading zero if the length is odd
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
const
|
|
36
|
-
const buffer = new Uint8Array(
|
|
35
|
+
const lengthS = input.length / 2;
|
|
36
|
+
const buffer = new Uint8Array(lengthS);
|
|
37
37
|
|
|
38
|
-
for (let i = 0; i <
|
|
39
|
-
// Use substring(i * 2, i * 2 + 2) to replace substr(i * 2, 2)
|
|
38
|
+
for (let i = 0; i < lengthS; i++) {
|
|
40
39
|
buffer[i] = parseInt(input.substring(i * 2, i * 2 + 2), 16);
|
|
41
40
|
}
|
|
42
41
|
|
|
@@ -55,8 +54,8 @@ export class BufferHelper {
|
|
|
55
54
|
return BigInt('0x' + hex);
|
|
56
55
|
}
|
|
57
56
|
|
|
58
|
-
public static valueToUint8Array(value: bigint): Uint8Array {
|
|
59
|
-
const valueHex = value.toString(16).padStart(
|
|
57
|
+
public static valueToUint8Array(value: bigint, length: number = 32): Uint8Array {
|
|
58
|
+
const valueHex = value.toString(16).padStart(length * 2, '0');
|
|
60
59
|
|
|
61
60
|
return BufferHelper.hexToUint8Array(valueHex);
|
|
62
61
|
}
|