@btc-vision/transaction 1.0.111 → 1.0.113
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/generators/Generator.d.ts +2 -0
- package/browser/index.js +1 -1
- package/browser/keypair/AddressVerificator.d.ts +15 -3
- package/browser/keypair/EcKeyPair.d.ts +9 -4
- package/browser/keypair/Wallet.d.ts +1 -0
- package/browser/signer/TweakedSigner.d.ts +2 -2
- package/browser/transaction/builders/FundingTransaction.d.ts +2 -1
- package/browser/transaction/builders/MultiSignTransaction.d.ts +2 -1
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +1 -1
- package/browser/transaction/builders/TransactionBuilder.d.ts +3 -2
- package/browser/transaction/shared/TweakedTransaction.d.ts +8 -7
- package/browser/verification/TapscriptVerificator.d.ts +1 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/generators/Generator.d.ts +2 -0
- package/build/generators/Generator.js +5 -0
- package/build/generators/builders/CalldataGenerator.js +4 -2
- package/build/generators/builders/DeploymentGenerator.js +7 -4
- package/build/keypair/AddressVerificator.d.ts +15 -3
- package/build/keypair/AddressVerificator.js +74 -3
- package/build/keypair/EcKeyPair.d.ts +9 -4
- package/build/keypair/EcKeyPair.js +69 -7
- package/build/keypair/Wallet.d.ts +1 -0
- package/build/keypair/Wallet.js +5 -4
- package/build/signer/TweakedSigner.d.ts +2 -2
- package/build/signer/TweakedSigner.js +1 -1
- package/build/transaction/builders/CustomScriptTransaction.js +3 -3
- package/build/transaction/builders/DeploymentTransaction.js +4 -4
- package/build/transaction/builders/FundingTransaction.d.ts +2 -1
- package/build/transaction/builders/FundingTransaction.js +18 -4
- package/build/transaction/builders/MultiSignTransaction.d.ts +2 -1
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +1 -1
- package/build/transaction/builders/SharedInteractionTransaction.js +4 -4
- package/build/transaction/builders/TransactionBuilder.d.ts +3 -2
- package/build/transaction/builders/TransactionBuilder.js +7 -2
- package/build/transaction/builders/UnwrapTransaction.js +2 -2
- package/build/transaction/shared/TweakedTransaction.d.ts +8 -7
- package/build/transaction/shared/TweakedTransaction.js +1 -1
- package/build/verification/TapscriptVerificator.d.ts +1 -1
- package/build/verification/TapscriptVerificator.js +2 -2
- package/package.json +2 -1
- package/src/_version.ts +1 -1
- package/src/generators/Generator.ts +12 -0
- package/src/generators/builders/CalldataGenerator.ts +6 -3
- package/src/generators/builders/DeploymentGenerator.ts +9 -4
- package/src/keypair/AddressVerificator.ts +144 -5
- package/src/keypair/EcKeyPair.ts +149 -13
- package/src/keypair/Wallet.ts +11 -3
- package/src/signer/TweakedSigner.ts +3 -2
- package/src/transaction/builders/CustomScriptTransaction.ts +6 -5
- package/src/transaction/builders/DeploymentTransaction.ts +6 -5
- package/src/transaction/builders/FundingTransaction.ts +18 -5
- package/src/transaction/builders/MultiSignTransaction.ts +6 -2
- package/src/transaction/builders/SharedInteractionTransaction.ts +5 -5
- package/src/transaction/builders/TransactionBuilder.ts +36 -10
- package/src/transaction/builders/UnwrapSegwitTransaction.ts +7 -3
- package/src/transaction/builders/UnwrapTransaction.ts +2 -2
- package/src/transaction/builders/WrapTransaction.ts +1 -6
- package/src/transaction/shared/TweakedTransaction.ts +12 -12
- package/src/verification/TapscriptVerificator.ts +3 -3
|
@@ -10,6 +10,7 @@ import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
|
10
10
|
import { IWBTCUTXODocument, PsbtTransaction, VaultUTXOs } from '../processor/PsbtTransaction.js';
|
|
11
11
|
import { PsbtInputExtended, PsbtOutputExtended } from '../interfaces/Tap.js';
|
|
12
12
|
import { currentConsensusConfig } from '../../consensus/ConsensusConfig.js';
|
|
13
|
+
import { ECPairInterface } from 'ecpair';
|
|
13
14
|
|
|
14
15
|
const abiCoder: ABICoder = new ABICoder();
|
|
15
16
|
|
|
@@ -196,7 +197,10 @@ export class UnwrapSegwitTransaction extends SharedInteractionTransaction<Transa
|
|
|
196
197
|
* @returns {Promise<boolean>}
|
|
197
198
|
* @throws {Error} - If something went wrong while building the transaction
|
|
198
199
|
*/
|
|
199
|
-
protected async internalBuildTransaction(
|
|
200
|
+
protected async internalBuildTransaction(
|
|
201
|
+
transaction: Psbt,
|
|
202
|
+
checkPartialSigs: boolean = false,
|
|
203
|
+
): Promise<boolean> {
|
|
200
204
|
if (transaction.data.inputs.length === 0) {
|
|
201
205
|
const inputs: PsbtInputExtended[] = this.getInputs();
|
|
202
206
|
const outputs: PsbtOutputExtended[] = this.getOutputs();
|
|
@@ -300,12 +304,12 @@ export class UnwrapSegwitTransaction extends SharedInteractionTransaction<Transa
|
|
|
300
304
|
/**
|
|
301
305
|
* @description Add vault inputs to the transaction
|
|
302
306
|
* @param {VaultUTXOs} vault The vault UTXOs
|
|
303
|
-
* @param {Signer} [firstSigner] The first signer
|
|
307
|
+
* @param {Signer | ECPairInterface} [firstSigner] The first signer
|
|
304
308
|
* @private
|
|
305
309
|
*/
|
|
306
310
|
private async addVaultInputs(
|
|
307
311
|
vault: VaultUTXOs,
|
|
308
|
-
firstSigner: Signer = this.signer,
|
|
312
|
+
firstSigner: Signer | ECPairInterface = this.signer,
|
|
309
313
|
): Promise<void> {
|
|
310
314
|
const p2wshOutput = this.generateMultiSignRedeemScript(vault.publicKeys, vault.minimum);
|
|
311
315
|
for (const utxo of vault.utxos) {
|
|
@@ -109,7 +109,7 @@ export class UnwrapTransaction extends SharedInteractionTransaction<TransactionT
|
|
|
109
109
|
this.contractSecret = this.generateSecret();
|
|
110
110
|
|
|
111
111
|
this.calldataGenerator = new CalldataGenerator(
|
|
112
|
-
|
|
112
|
+
Buffer.from(this.signer.publicKey),
|
|
113
113
|
this.scriptSignerXOnlyPubKey(),
|
|
114
114
|
this.network,
|
|
115
115
|
);
|
|
@@ -372,7 +372,7 @@ export class UnwrapTransaction extends SharedInteractionTransaction<TransactionT
|
|
|
372
372
|
|
|
373
373
|
return [
|
|
374
374
|
this.contractSecret,
|
|
375
|
-
toXOnly(this.signer.publicKey),
|
|
375
|
+
toXOnly(Buffer.from(this.signer.publicKey)),
|
|
376
376
|
input.tapScriptSig[0].signature,
|
|
377
377
|
input.tapScriptSig[1].signature,
|
|
378
378
|
];
|
|
@@ -6,7 +6,6 @@ import { SharedInteractionTransaction } from './SharedInteractionTransaction.js'
|
|
|
6
6
|
import { wBTC } from '../../metadata/contracts/wBTC.js';
|
|
7
7
|
import { ABICoder, Address, BinaryWriter, Selector } from '@btc-vision/bsi-binary';
|
|
8
8
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
9
|
-
import { ECPairInterface } from 'ecpair';
|
|
10
9
|
import { WrappedGeneration } from '../../wbtc/WrappedGenerationParameters.js';
|
|
11
10
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
12
11
|
import { AddressVerificator } from '../../keypair/AddressVerificator.js';
|
|
@@ -94,11 +93,7 @@ export class WrapTransaction extends SharedInteractionTransaction<TransactionTyp
|
|
|
94
93
|
|
|
95
94
|
const receiver: Address =
|
|
96
95
|
parameters.receiver ||
|
|
97
|
-
TransactionBuilder.getFrom(
|
|
98
|
-
parameters.from,
|
|
99
|
-
parameters.signer as ECPairInterface,
|
|
100
|
-
parameters.network,
|
|
101
|
-
);
|
|
96
|
+
TransactionBuilder.getFrom(parameters.from, parameters.signer, parameters.network);
|
|
102
97
|
|
|
103
98
|
parameters.calldata = WrapTransaction.generateMintCalldata(
|
|
104
99
|
parameters.amount,
|
|
@@ -11,7 +11,7 @@ import { ChainId } from '../../network/ChainId.js';
|
|
|
11
11
|
import { varuint } from 'bitcoinjs-lib/src/bufferutils.js';
|
|
12
12
|
|
|
13
13
|
export interface ITweakedTransactionData {
|
|
14
|
-
readonly signer: Signer;
|
|
14
|
+
readonly signer: Signer | ECPairInterface;
|
|
15
15
|
readonly network: Network;
|
|
16
16
|
readonly chainId?: ChainId;
|
|
17
17
|
readonly nonWitnessUtxo?: Buffer;
|
|
@@ -34,11 +34,11 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
34
34
|
/**
|
|
35
35
|
* @description Was the transaction signed?
|
|
36
36
|
*/
|
|
37
|
-
protected signer: Signer;
|
|
37
|
+
protected signer: Signer | ECPairInterface;
|
|
38
38
|
/**
|
|
39
39
|
* @description Tweaked signer
|
|
40
40
|
*/
|
|
41
|
-
protected tweakedSigner?:
|
|
41
|
+
protected tweakedSigner?: ECPairInterface;
|
|
42
42
|
/**
|
|
43
43
|
* @description The network of the transaction
|
|
44
44
|
*/
|
|
@@ -190,7 +190,7 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
190
190
|
transaction: Psbt,
|
|
191
191
|
input: PsbtInput,
|
|
192
192
|
i: number,
|
|
193
|
-
signer: Signer,
|
|
193
|
+
signer: Signer | ECPairInterface,
|
|
194
194
|
sighashTypes: number[],
|
|
195
195
|
): void {
|
|
196
196
|
if (sighashTypes && sighashTypes[0]) input.sighashType = sighashTypes[0];
|
|
@@ -336,9 +336,9 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
336
336
|
/**
|
|
337
337
|
* Returns the signer key.
|
|
338
338
|
* @protected
|
|
339
|
-
* @returns {Signer}
|
|
339
|
+
* @returns {Signer | ECPairInterface}
|
|
340
340
|
*/
|
|
341
|
-
protected getSignerKey(): Signer {
|
|
341
|
+
protected getSignerKey(): Signer | ECPairInterface {
|
|
342
342
|
return this.signer;
|
|
343
343
|
}
|
|
344
344
|
|
|
@@ -354,7 +354,7 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
354
354
|
transaction: Psbt,
|
|
355
355
|
input: PsbtInput,
|
|
356
356
|
i: number,
|
|
357
|
-
signer?: Signer,
|
|
357
|
+
signer?: Signer | ECPairInterface,
|
|
358
358
|
): Promise<void> {
|
|
359
359
|
const signHash =
|
|
360
360
|
this.sighashTypes && this.sighashTypes.length
|
|
@@ -367,7 +367,7 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
367
367
|
if (input.tapInternalKey) {
|
|
368
368
|
if (!this.tweakedSigner) this.tweakSigner();
|
|
369
369
|
|
|
370
|
-
let tweakedSigner:
|
|
370
|
+
let tweakedSigner: ECPairInterface | undefined;
|
|
371
371
|
if (signer !== this.signer) {
|
|
372
372
|
tweakedSigner = this.getTweakedSigner(true, signer);
|
|
373
373
|
} else {
|
|
@@ -481,7 +481,7 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
481
481
|
* @returns {Buffer}
|
|
482
482
|
*/
|
|
483
483
|
protected internalPubKeyToXOnly(): Buffer {
|
|
484
|
-
return toXOnly(this.signer.publicKey);
|
|
484
|
+
return toXOnly(Buffer.from(this.signer.publicKey));
|
|
485
485
|
}
|
|
486
486
|
|
|
487
487
|
/**
|
|
@@ -507,12 +507,12 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
507
507
|
/**
|
|
508
508
|
* Get the tweaked signer
|
|
509
509
|
* @private
|
|
510
|
-
* @returns {
|
|
510
|
+
* @returns {ECPairInterface} The tweaked signer
|
|
511
511
|
*/
|
|
512
512
|
protected getTweakedSigner(
|
|
513
513
|
useTweakedHash: boolean = false,
|
|
514
|
-
signer: Signer = this.signer,
|
|
515
|
-
):
|
|
514
|
+
signer: Signer | ECPairInterface = this.signer,
|
|
515
|
+
): ECPairInterface | undefined {
|
|
516
516
|
const settings: TweakSettings = {
|
|
517
517
|
network: this.network,
|
|
518
518
|
};
|
|
@@ -6,7 +6,7 @@ import { TransactionBuilder } from '../transaction/builders/TransactionBuilder.j
|
|
|
6
6
|
import { AddressGenerator } from '../generators/AddressGenerator.js';
|
|
7
7
|
|
|
8
8
|
export interface ContractAddressVerificationParams {
|
|
9
|
-
readonly
|
|
9
|
+
readonly deployerPubKey: Buffer;
|
|
10
10
|
readonly contractSaltPubKey: Buffer;
|
|
11
11
|
readonly originalSalt: Buffer;
|
|
12
12
|
readonly bytecode: Buffer;
|
|
@@ -22,7 +22,7 @@ export class TapscriptVerificator {
|
|
|
22
22
|
): string | undefined {
|
|
23
23
|
const network = params.network || networks.bitcoin;
|
|
24
24
|
const scriptBuilder: DeploymentGenerator = new DeploymentGenerator(
|
|
25
|
-
params.
|
|
25
|
+
params.deployerPubKey,
|
|
26
26
|
toXOnly(params.contractSaltPubKey),
|
|
27
27
|
network,
|
|
28
28
|
);
|
|
@@ -80,7 +80,7 @@ export class TapscriptVerificator {
|
|
|
80
80
|
const network = params.network || networks.bitcoin;
|
|
81
81
|
|
|
82
82
|
const transactionData: Payment = {
|
|
83
|
-
internalPubkey: params.
|
|
83
|
+
internalPubkey: toXOnly(params.deployerPubKey),
|
|
84
84
|
network: network,
|
|
85
85
|
scriptTree: scriptTree,
|
|
86
86
|
};
|