@btc-vision/transaction 1.5.0 → 1.5.1
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/generators/builders/DeploymentGenerator.d.ts +2 -0
- package/browser/index.js +1 -1
- package/browser/transaction/builders/CustomScriptTransaction.d.ts +3 -3
- package/browser/transaction/builders/DeploymentTransaction.d.ts +3 -3
- package/browser/transaction/builders/MultiSignTransaction.d.ts +5 -5
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +5 -5
- package/browser/transaction/shared/TweakedTransaction.d.ts +5 -5
- package/build/generators/builders/DeploymentGenerator.d.ts +2 -0
- package/build/generators/builders/DeploymentGenerator.js +2 -0
- package/build/transaction/builders/CustomScriptTransaction.d.ts +3 -3
- package/build/transaction/builders/CustomScriptTransaction.js +5 -3
- package/build/transaction/builders/DeploymentTransaction.d.ts +3 -3
- package/build/transaction/builders/DeploymentTransaction.js +7 -6
- package/build/transaction/builders/MultiSignTransaction.d.ts +5 -5
- package/build/transaction/builders/MultiSignTransaction.js +5 -1
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +5 -5
- package/build/transaction/builders/SharedInteractionTransaction.js +5 -1
- package/build/transaction/shared/TweakedTransaction.d.ts +5 -5
- package/build/transaction/shared/TweakedTransaction.js +3 -1
- package/build/verification/TapscriptVerificator.js +0 -1
- package/package.json +6 -6
- package/src/generators/builders/DeploymentGenerator.ts +4 -0
- package/src/transaction/builders/CustomScriptTransaction.ts +13 -7
- package/src/transaction/builders/DeploymentTransaction.ts +20 -12
- package/src/transaction/builders/MultiSignTransaction.ts +10 -6
- package/src/transaction/builders/SharedInteractionTransaction.ts +9 -5
- package/src/transaction/shared/TweakedTransaction.ts +8 -4
- package/src/verification/TapscriptVerificator.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P2TRPayment, Psbt, PsbtInput, Stack } from '@btc-vision/bitcoin';
|
|
2
2
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
3
3
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
4
4
|
import { SharedInteractionParameters } from '../interfaces/ITransactionParameters.js';
|
|
@@ -30,8 +30,8 @@ export declare class CustomScriptTransaction extends TransactionBuilder<Transact
|
|
|
30
30
|
protected contractSignerXOnlyPubKey(): Buffer;
|
|
31
31
|
protected buildTransaction(): Promise<void>;
|
|
32
32
|
protected signInputs(transaction: Psbt): Promise<void>;
|
|
33
|
-
protected generateScriptAddress():
|
|
34
|
-
protected generateTapData():
|
|
33
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
34
|
+
protected generateTapData(): P2TRPayment;
|
|
35
35
|
protected getScriptSolution(input: PsbtInput): Buffer[];
|
|
36
36
|
private getContractSeed;
|
|
37
37
|
private customFinalizer;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
2
|
import { IDeploymentParameters } from '../interfaces/ITransactionParameters.js';
|
|
3
|
-
import {
|
|
3
|
+
import { P2TRPayment, Psbt } from '@btc-vision/bitcoin';
|
|
4
4
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
5
5
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
6
6
|
import { Address } from '../../keypair/Address.js';
|
|
@@ -36,8 +36,8 @@ export declare class DeploymentTransaction extends TransactionBuilder<Transactio
|
|
|
36
36
|
protected buildTransaction(): Promise<void>;
|
|
37
37
|
protected signInputsWalletBased(transaction: Psbt): Promise<void>;
|
|
38
38
|
protected signInputs(transaction: Psbt): Promise<void>;
|
|
39
|
-
protected generateScriptAddress():
|
|
40
|
-
protected generateTapData():
|
|
39
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
40
|
+
protected generateTapData(): P2TRPayment;
|
|
41
41
|
private verifyCalldata;
|
|
42
42
|
private verifyBytecode;
|
|
43
43
|
private getContractSeed;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P2TRPayment, Psbt, PsbtInput, Signer, TapScriptSig, Taptree } from '@btc-vision/bitcoin';
|
|
2
2
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
3
3
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
4
4
|
import { ITransactionParameters } from '../interfaces/ITransactionParameters.js';
|
|
@@ -21,8 +21,8 @@ export declare class MultiSignTransaction extends TransactionBuilder<Transaction
|
|
|
21
21
|
static readonly signHashTypesArray: number[];
|
|
22
22
|
static readonly numsPoint: Buffer<ArrayBuffer>;
|
|
23
23
|
type: TransactionType.MULTI_SIG;
|
|
24
|
-
protected targetScriptRedeem:
|
|
25
|
-
protected leftOverFundsScriptRedeem:
|
|
24
|
+
protected targetScriptRedeem: P2TRPayment | null;
|
|
25
|
+
protected leftOverFundsScriptRedeem: P2TRPayment | null;
|
|
26
26
|
protected readonly compiledTargetScript: Buffer;
|
|
27
27
|
protected readonly scriptTree: Taptree;
|
|
28
28
|
protected readonly publicKeys: Buffer[];
|
|
@@ -49,8 +49,8 @@ export declare class MultiSignTransaction extends TransactionBuilder<Transaction
|
|
|
49
49
|
protected buildTransaction(): Promise<void>;
|
|
50
50
|
protected internalBuildTransaction(transaction: Psbt, checkPartialSigs?: boolean): Promise<boolean>;
|
|
51
51
|
protected signInputs(_transaction: Psbt): Promise<void>;
|
|
52
|
-
protected generateScriptAddress():
|
|
53
|
-
protected generateTapData():
|
|
52
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
53
|
+
protected generateTapData(): P2TRPayment;
|
|
54
54
|
protected getScriptSolution(input: PsbtInput): Buffer[];
|
|
55
55
|
protected getScriptTree(): Taptree;
|
|
56
56
|
private getTotalOutputAmount;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P2TRPayment, Psbt, PsbtInput, Signer, Taptree } from '@btc-vision/bitcoin';
|
|
2
2
|
import { ECPairInterface } from 'ecpair';
|
|
3
3
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
4
4
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
@@ -8,8 +8,8 @@ import { IMineableReward } from '../mineable/ChallengeGenerator.js';
|
|
|
8
8
|
export declare abstract class SharedInteractionTransaction<T extends TransactionType> extends TransactionBuilder<T> {
|
|
9
9
|
static readonly MAXIMUM_CALLDATA_SIZE: number;
|
|
10
10
|
readonly randomBytes: Buffer;
|
|
11
|
-
protected targetScriptRedeem:
|
|
12
|
-
protected leftOverFundsScriptRedeem:
|
|
11
|
+
protected targetScriptRedeem: P2TRPayment | null;
|
|
12
|
+
protected leftOverFundsScriptRedeem: P2TRPayment | null;
|
|
13
13
|
protected abstract readonly compiledTargetScript: Buffer;
|
|
14
14
|
protected abstract readonly scriptTree: Taptree;
|
|
15
15
|
protected readonly preimage: Buffer;
|
|
@@ -28,8 +28,8 @@ export declare abstract class SharedInteractionTransaction<T extends Transaction
|
|
|
28
28
|
protected generateKeyPairFromSeed(): ECPairInterface;
|
|
29
29
|
protected buildTransaction(): Promise<void>;
|
|
30
30
|
protected signInputs(transaction: Psbt): Promise<void>;
|
|
31
|
-
protected generateScriptAddress():
|
|
32
|
-
protected generateTapData():
|
|
31
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
32
|
+
protected generateTapData(): P2TRPayment;
|
|
33
33
|
protected getScriptSolution(input: PsbtInput): Buffer[];
|
|
34
34
|
protected getScriptTree(): Taptree;
|
|
35
35
|
protected customFinalizer: (_inputIndex: number, input: PsbtInput) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@btc-vision/logger';
|
|
2
|
-
import { Network,
|
|
2
|
+
import { Network, P2TRPayment, Psbt, PsbtInput, PsbtInputExtended, Signer, Transaction } from '@btc-vision/bitcoin';
|
|
3
3
|
import { ECPairInterface } from 'ecpair';
|
|
4
4
|
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
5
5
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
@@ -24,8 +24,8 @@ export declare abstract class TweakedTransaction extends Logger {
|
|
|
24
24
|
protected signed: boolean;
|
|
25
25
|
protected abstract readonly transaction: Psbt;
|
|
26
26
|
protected sighashTypes: number[] | undefined;
|
|
27
|
-
protected scriptData:
|
|
28
|
-
protected tapData:
|
|
27
|
+
protected scriptData: P2TRPayment | null;
|
|
28
|
+
protected tapData: P2TRPayment | null;
|
|
29
29
|
protected readonly inputs: PsbtInputExtended[];
|
|
30
30
|
protected sequence: number;
|
|
31
31
|
protected tapLeafScript: TapLeafScript | null;
|
|
@@ -45,8 +45,8 @@ export declare abstract class TweakedTransaction extends Logger {
|
|
|
45
45
|
disableRBF(): void;
|
|
46
46
|
getTweakerHash(): Buffer | undefined;
|
|
47
47
|
preEstimateTransactionFees(feeRate: bigint, numInputs: bigint, numOutputs: bigint, numSignatures: bigint, numPubkeys: bigint): bigint;
|
|
48
|
-
protected generateTapData():
|
|
49
|
-
protected generateScriptAddress():
|
|
48
|
+
protected generateTapData(): P2TRPayment;
|
|
49
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
50
50
|
protected getSignerKey(): Signer | ECPairInterface;
|
|
51
51
|
protected signInput(transaction: Psbt, input: PsbtInput, i: number, signer: Signer | ECPairInterface, reverse?: boolean, errored?: boolean): Promise<void>;
|
|
52
52
|
protected splitArray<T>(arr: T[], chunkSize: number): T[][];
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Network } from '@btc-vision/bitcoin';
|
|
2
2
|
import { Generator } from '../Generator.js';
|
|
3
|
+
export declare const OPNET_DEPLOYMENT_VERSION = 0;
|
|
4
|
+
export declare const versionBuffer: Buffer<ArrayBuffer>;
|
|
3
5
|
export declare class DeploymentGenerator extends Generator {
|
|
4
6
|
constructor(senderPubKey: Buffer, contractSaltPubKey: Buffer, network?: Network);
|
|
5
7
|
compile(contractBytecode: Buffer, contractSalt: Buffer, preimage: Buffer, maxPriority: bigint, calldata?: Buffer): Buffer;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { crypto, networks, opcodes, script } from '@btc-vision/bitcoin';
|
|
2
2
|
import { Generator } from '../Generator.js';
|
|
3
|
+
export const OPNET_DEPLOYMENT_VERSION = 0x00;
|
|
4
|
+
export const versionBuffer = Buffer.from([OPNET_DEPLOYMENT_VERSION]);
|
|
3
5
|
export class DeploymentGenerator extends Generator {
|
|
4
6
|
constructor(senderPubKey, contractSaltPubKey, network = networks.bitcoin) {
|
|
5
7
|
super(senderPubKey, contractSaltPubKey, network);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P2TRPayment, Psbt, PsbtInput, Stack } from '@btc-vision/bitcoin';
|
|
2
2
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
3
3
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
4
4
|
import { SharedInteractionParameters } from '../interfaces/ITransactionParameters.js';
|
|
@@ -30,8 +30,8 @@ export declare class CustomScriptTransaction extends TransactionBuilder<Transact
|
|
|
30
30
|
protected contractSignerXOnlyPubKey(): Buffer;
|
|
31
31
|
protected buildTransaction(): Promise<void>;
|
|
32
32
|
protected signInputs(transaction: Psbt): Promise<void>;
|
|
33
|
-
protected generateScriptAddress():
|
|
34
|
-
protected generateTapData():
|
|
33
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
34
|
+
protected generateTapData(): P2TRPayment;
|
|
35
35
|
protected getScriptSolution(input: PsbtInput): Buffer[];
|
|
36
36
|
private getContractSeed;
|
|
37
37
|
private customFinalizer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { crypto as bitCrypto, toXOnly, } from '@btc-vision/bitcoin';
|
|
1
|
+
import { crypto as bitCrypto, PaymentType, toXOnly, } from '@btc-vision/bitcoin';
|
|
2
2
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
3
3
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
4
4
|
import { CustomGenerator } from '../../generators/builders/CustomGenerator.js';
|
|
@@ -110,6 +110,7 @@ export class CustomScriptTransaction extends TransactionBuilder {
|
|
|
110
110
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
111
111
|
network: this.network,
|
|
112
112
|
scriptTree: this.scriptTree,
|
|
113
|
+
name: PaymentType.P2TR,
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
116
|
generateTapData() {
|
|
@@ -127,6 +128,7 @@ export class CustomScriptTransaction extends TransactionBuilder {
|
|
|
127
128
|
network: this.network,
|
|
128
129
|
scriptTree: this.scriptTree,
|
|
129
130
|
redeem: selectedRedeem,
|
|
131
|
+
name: PaymentType.P2TR,
|
|
130
132
|
};
|
|
131
133
|
}
|
|
132
134
|
getScriptSolution(input) {
|
|
@@ -153,12 +155,12 @@ export class CustomScriptTransaction extends TransactionBuilder {
|
|
|
153
155
|
}
|
|
154
156
|
generateRedeemScripts() {
|
|
155
157
|
this.targetScriptRedeem = {
|
|
156
|
-
|
|
158
|
+
name: PaymentType.P2TR,
|
|
157
159
|
output: this.compiledTargetScript,
|
|
158
160
|
redeemVersion: 192,
|
|
159
161
|
};
|
|
160
162
|
this.leftOverFundsScriptRedeem = {
|
|
161
|
-
|
|
163
|
+
name: PaymentType.P2TR,
|
|
162
164
|
output: this.getLeafScript(),
|
|
163
165
|
redeemVersion: 192,
|
|
164
166
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
2
|
import { IDeploymentParameters } from '../interfaces/ITransactionParameters.js';
|
|
3
|
-
import {
|
|
3
|
+
import { P2TRPayment, Psbt } from '@btc-vision/bitcoin';
|
|
4
4
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
5
5
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
6
6
|
import { Address } from '../../keypair/Address.js';
|
|
@@ -36,8 +36,8 @@ export declare class DeploymentTransaction extends TransactionBuilder<Transactio
|
|
|
36
36
|
protected buildTransaction(): Promise<void>;
|
|
37
37
|
protected signInputsWalletBased(transaction: Psbt): Promise<void>;
|
|
38
38
|
protected signInputs(transaction: Psbt): Promise<void>;
|
|
39
|
-
protected generateScriptAddress():
|
|
40
|
-
protected generateTapData():
|
|
39
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
40
|
+
protected generateTapData(): P2TRPayment;
|
|
41
41
|
private verifyCalldata;
|
|
42
42
|
private verifyBytecode;
|
|
43
43
|
private getContractSeed;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
2
|
-
import { crypto as bitCrypto, toXOnly, } from '@btc-vision/bitcoin';
|
|
2
|
+
import { crypto as bitCrypto, PaymentType, toXOnly, } from '@btc-vision/bitcoin';
|
|
3
3
|
import { MINIMUM_AMOUNT_CA, MINIMUM_AMOUNT_REWARD, TransactionBuilder, } from './TransactionBuilder.js';
|
|
4
|
-
import { DeploymentGenerator } from '../../generators/builders/DeploymentGenerator.js';
|
|
4
|
+
import { DeploymentGenerator, versionBuffer, } from '../../generators/builders/DeploymentGenerator.js';
|
|
5
5
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
6
6
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
7
7
|
import { Compressor } from '../../bytecode/Compressor.js';
|
|
8
8
|
import { SharedInteractionTransaction } from './SharedInteractionTransaction.js';
|
|
9
9
|
import { Address } from '../../keypair/Address.js';
|
|
10
10
|
import { ChallengeGenerator } from '../mineable/ChallengeGenerator.js';
|
|
11
|
-
const p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;
|
|
12
11
|
export class DeploymentTransaction extends TransactionBuilder {
|
|
13
12
|
constructor(parameters) {
|
|
14
13
|
super(parameters);
|
|
@@ -36,7 +35,7 @@ export class DeploymentTransaction extends TransactionBuilder {
|
|
|
36
35
|
finalScriptWitness: TransactionBuilder.witnessStackToScriptWitness(witness),
|
|
37
36
|
};
|
|
38
37
|
};
|
|
39
|
-
this.bytecode = Compressor.compress(parameters.bytecode);
|
|
38
|
+
this.bytecode = Compressor.compress(Buffer.concat([versionBuffer, parameters.bytecode]));
|
|
40
39
|
this.verifyBytecode();
|
|
41
40
|
if (parameters.calldata) {
|
|
42
41
|
this.calldata = parameters.calldata;
|
|
@@ -170,6 +169,7 @@ export class DeploymentTransaction extends TransactionBuilder {
|
|
|
170
169
|
}
|
|
171
170
|
generateScriptAddress() {
|
|
172
171
|
return {
|
|
172
|
+
name: PaymentType.P2TR,
|
|
173
173
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
174
174
|
network: this.network,
|
|
175
175
|
scriptTree: this.scriptTree,
|
|
@@ -186,6 +186,7 @@ export class DeploymentTransaction extends TransactionBuilder {
|
|
|
186
186
|
throw new Error('Script tree is required');
|
|
187
187
|
}
|
|
188
188
|
return {
|
|
189
|
+
name: PaymentType.P2TR,
|
|
189
190
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
190
191
|
network: this.network,
|
|
191
192
|
scriptTree: this.scriptTree,
|
|
@@ -224,12 +225,12 @@ export class DeploymentTransaction extends TransactionBuilder {
|
|
|
224
225
|
}
|
|
225
226
|
generateRedeemScripts() {
|
|
226
227
|
this.targetScriptRedeem = {
|
|
227
|
-
|
|
228
|
+
name: PaymentType.P2TR,
|
|
228
229
|
output: this.compiledTargetScript,
|
|
229
230
|
redeemVersion: 192,
|
|
230
231
|
};
|
|
231
232
|
this.leftOverFundsScriptRedeem = {
|
|
232
|
-
|
|
233
|
+
name: PaymentType.P2TR,
|
|
233
234
|
output: this.getLeafScript(),
|
|
234
235
|
redeemVersion: 192,
|
|
235
236
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P2TRPayment, Psbt, PsbtInput, Signer, TapScriptSig, Taptree } from '@btc-vision/bitcoin';
|
|
2
2
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
3
3
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
4
4
|
import { ITransactionParameters } from '../interfaces/ITransactionParameters.js';
|
|
@@ -21,8 +21,8 @@ export declare class MultiSignTransaction extends TransactionBuilder<Transaction
|
|
|
21
21
|
static readonly signHashTypesArray: number[];
|
|
22
22
|
static readonly numsPoint: Buffer<ArrayBuffer>;
|
|
23
23
|
type: TransactionType.MULTI_SIG;
|
|
24
|
-
protected targetScriptRedeem:
|
|
25
|
-
protected leftOverFundsScriptRedeem:
|
|
24
|
+
protected targetScriptRedeem: P2TRPayment | null;
|
|
25
|
+
protected leftOverFundsScriptRedeem: P2TRPayment | null;
|
|
26
26
|
protected readonly compiledTargetScript: Buffer;
|
|
27
27
|
protected readonly scriptTree: Taptree;
|
|
28
28
|
protected readonly publicKeys: Buffer[];
|
|
@@ -49,8 +49,8 @@ export declare class MultiSignTransaction extends TransactionBuilder<Transaction
|
|
|
49
49
|
protected buildTransaction(): Promise<void>;
|
|
50
50
|
protected internalBuildTransaction(transaction: Psbt, checkPartialSigs?: boolean): Promise<boolean>;
|
|
51
51
|
protected signInputs(_transaction: Psbt): Promise<void>;
|
|
52
|
-
protected generateScriptAddress():
|
|
53
|
-
protected generateTapData():
|
|
52
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
53
|
+
protected generateTapData(): P2TRPayment;
|
|
54
54
|
protected getScriptSolution(input: PsbtInput): Buffer[];
|
|
55
55
|
protected getScriptTree(): Taptree;
|
|
56
56
|
private getTotalOutputAmount;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { crypto as bitcoinCrypto, opcodes, Psbt, script, toXOnly, } from '@btc-vision/bitcoin';
|
|
1
|
+
import { crypto as bitcoinCrypto, opcodes, PaymentType, Psbt, script, toXOnly, } from '@btc-vision/bitcoin';
|
|
2
2
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
3
3
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
4
4
|
import { MultiSignGenerator } from '../../generators/builders/MultiSignGenerator.js';
|
|
@@ -256,6 +256,7 @@ export class MultiSignTransaction extends TransactionBuilder {
|
|
|
256
256
|
internalPubkey: toXOnly(MultiSignTransaction.numsPoint),
|
|
257
257
|
network: this.network,
|
|
258
258
|
scriptTree: this.scriptTree,
|
|
259
|
+
name: PaymentType.P2TR,
|
|
259
260
|
};
|
|
260
261
|
}
|
|
261
262
|
generateTapData() {
|
|
@@ -271,6 +272,7 @@ export class MultiSignTransaction extends TransactionBuilder {
|
|
|
271
272
|
network: this.network,
|
|
272
273
|
scriptTree: this.scriptTree,
|
|
273
274
|
redeem: selectedRedeem,
|
|
275
|
+
name: PaymentType.P2TR,
|
|
274
276
|
};
|
|
275
277
|
}
|
|
276
278
|
getScriptSolution(input) {
|
|
@@ -307,10 +309,12 @@ export class MultiSignTransaction extends TransactionBuilder {
|
|
|
307
309
|
}
|
|
308
310
|
generateRedeemScripts() {
|
|
309
311
|
this.targetScriptRedeem = {
|
|
312
|
+
name: PaymentType.P2TR,
|
|
310
313
|
output: this.compiledTargetScript,
|
|
311
314
|
redeemVersion: 192,
|
|
312
315
|
};
|
|
313
316
|
this.leftOverFundsScriptRedeem = {
|
|
317
|
+
name: PaymentType.P2TR,
|
|
314
318
|
output: MultiSignTransaction.LOCK_LEAF_SCRIPT,
|
|
315
319
|
redeemVersion: 192,
|
|
316
320
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P2TRPayment, Psbt, PsbtInput, Signer, Taptree } from '@btc-vision/bitcoin';
|
|
2
2
|
import { ECPairInterface } from 'ecpair';
|
|
3
3
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
4
4
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
@@ -8,8 +8,8 @@ import { IMineableReward } from '../mineable/ChallengeGenerator.js';
|
|
|
8
8
|
export declare abstract class SharedInteractionTransaction<T extends TransactionType> extends TransactionBuilder<T> {
|
|
9
9
|
static readonly MAXIMUM_CALLDATA_SIZE: number;
|
|
10
10
|
readonly randomBytes: Buffer;
|
|
11
|
-
protected targetScriptRedeem:
|
|
12
|
-
protected leftOverFundsScriptRedeem:
|
|
11
|
+
protected targetScriptRedeem: P2TRPayment | null;
|
|
12
|
+
protected leftOverFundsScriptRedeem: P2TRPayment | null;
|
|
13
13
|
protected abstract readonly compiledTargetScript: Buffer;
|
|
14
14
|
protected abstract readonly scriptTree: Taptree;
|
|
15
15
|
protected readonly preimage: Buffer;
|
|
@@ -28,8 +28,8 @@ export declare abstract class SharedInteractionTransaction<T extends Transaction
|
|
|
28
28
|
protected generateKeyPairFromSeed(): ECPairInterface;
|
|
29
29
|
protected buildTransaction(): Promise<void>;
|
|
30
30
|
protected signInputs(transaction: Psbt): Promise<void>;
|
|
31
|
-
protected generateScriptAddress():
|
|
32
|
-
protected generateTapData():
|
|
31
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
32
|
+
protected generateTapData(): P2TRPayment;
|
|
33
33
|
protected getScriptSolution(input: PsbtInput): Buffer[];
|
|
34
34
|
protected getScriptTree(): Taptree;
|
|
35
35
|
protected customFinalizer: (_inputIndex: number, input: PsbtInput) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { address, toXOnly } from '@btc-vision/bitcoin';
|
|
1
|
+
import { address, PaymentType, toXOnly } from '@btc-vision/bitcoin';
|
|
2
2
|
import { MINIMUM_AMOUNT_CA, MINIMUM_AMOUNT_REWARD, TransactionBuilder } from './TransactionBuilder.js';
|
|
3
3
|
import { CalldataGenerator } from '../../generators/builders/CalldataGenerator.js';
|
|
4
4
|
import { Compressor } from '../../bytecode/Compressor.js';
|
|
@@ -102,6 +102,7 @@ export class SharedInteractionTransaction extends TransactionBuilder {
|
|
|
102
102
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
103
103
|
network: this.network,
|
|
104
104
|
scriptTree: this.scriptTree,
|
|
105
|
+
name: PaymentType.P2TR,
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
108
|
generateTapData() {
|
|
@@ -119,6 +120,7 @@ export class SharedInteractionTransaction extends TransactionBuilder {
|
|
|
119
120
|
network: this.network,
|
|
120
121
|
scriptTree: this.scriptTree,
|
|
121
122
|
redeem: selectedRedeem,
|
|
123
|
+
name: PaymentType.P2TR,
|
|
122
124
|
};
|
|
123
125
|
}
|
|
124
126
|
getScriptSolution(input) {
|
|
@@ -219,10 +221,12 @@ export class SharedInteractionTransaction extends TransactionBuilder {
|
|
|
219
221
|
}
|
|
220
222
|
generateRedeemScripts() {
|
|
221
223
|
this.targetScriptRedeem = {
|
|
224
|
+
name: PaymentType.P2TR,
|
|
222
225
|
output: this.compiledTargetScript,
|
|
223
226
|
redeemVersion: 192,
|
|
224
227
|
};
|
|
225
228
|
this.leftOverFundsScriptRedeem = {
|
|
229
|
+
name: PaymentType.P2TR,
|
|
226
230
|
output: SharedInteractionTransaction.LOCK_LEAF_SCRIPT,
|
|
227
231
|
redeemVersion: 192,
|
|
228
232
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@btc-vision/logger';
|
|
2
|
-
import { Network,
|
|
2
|
+
import { Network, P2TRPayment, Psbt, PsbtInput, PsbtInputExtended, Signer, Transaction } from '@btc-vision/bitcoin';
|
|
3
3
|
import { ECPairInterface } from 'ecpair';
|
|
4
4
|
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
5
5
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
@@ -24,8 +24,8 @@ export declare abstract class TweakedTransaction extends Logger {
|
|
|
24
24
|
protected signed: boolean;
|
|
25
25
|
protected abstract readonly transaction: Psbt;
|
|
26
26
|
protected sighashTypes: number[] | undefined;
|
|
27
|
-
protected scriptData:
|
|
28
|
-
protected tapData:
|
|
27
|
+
protected scriptData: P2TRPayment | null;
|
|
28
|
+
protected tapData: P2TRPayment | null;
|
|
29
29
|
protected readonly inputs: PsbtInputExtended[];
|
|
30
30
|
protected sequence: number;
|
|
31
31
|
protected tapLeafScript: TapLeafScript | null;
|
|
@@ -45,8 +45,8 @@ export declare abstract class TweakedTransaction extends Logger {
|
|
|
45
45
|
disableRBF(): void;
|
|
46
46
|
getTweakerHash(): Buffer | undefined;
|
|
47
47
|
preEstimateTransactionFees(feeRate: bigint, numInputs: bigint, numOutputs: bigint, numSignatures: bigint, numPubkeys: bigint): bigint;
|
|
48
|
-
protected generateTapData():
|
|
49
|
-
protected generateScriptAddress():
|
|
48
|
+
protected generateTapData(): P2TRPayment;
|
|
49
|
+
protected generateScriptAddress(): P2TRPayment;
|
|
50
50
|
protected getSignerKey(): Signer | ECPairInterface;
|
|
51
51
|
protected signInput(transaction: Psbt, input: PsbtInput, i: number, signer: Signer | ECPairInterface, reverse?: boolean, errored?: boolean): Promise<void>;
|
|
52
52
|
protected splitArray<T>(arr: T[], chunkSize: number): T[][];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Logger } from '@btc-vision/logger';
|
|
2
|
-
import { address as bitAddress, crypto as bitCrypto, getFinalScripts, isP2MS, isP2PK, isP2PKH, isP2SHScript, isP2TR, isP2WPKH, isP2WSHScript, opcodes, payments, script, toXOnly, varuint, } from '@btc-vision/bitcoin';
|
|
2
|
+
import { address as bitAddress, crypto as bitCrypto, getFinalScripts, isP2MS, isP2PK, isP2PKH, isP2SHScript, isP2TR, isP2WPKH, isP2WSHScript, opcodes, payments, PaymentType, script, toXOnly, varuint, } from '@btc-vision/bitcoin';
|
|
3
3
|
import { TweakedSigner } from '../../signer/TweakedSigner.js';
|
|
4
4
|
import { canSignNonTaprootInput, isTaprootInput, pubkeyInScript, } from '../../signer/SignerUtils.js';
|
|
5
5
|
export var TransactionSequence;
|
|
@@ -140,12 +140,14 @@ export class TweakedTransaction extends Logger {
|
|
|
140
140
|
return {
|
|
141
141
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
142
142
|
network: this.network,
|
|
143
|
+
name: PaymentType.P2TR,
|
|
143
144
|
};
|
|
144
145
|
}
|
|
145
146
|
generateScriptAddress() {
|
|
146
147
|
return {
|
|
147
148
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
148
149
|
network: this.network,
|
|
150
|
+
name: PaymentType.P2TR,
|
|
149
151
|
};
|
|
150
152
|
}
|
|
151
153
|
getSignerKey() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@btc-vision/transaction",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.5.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"author": "BlobMaster41",
|
|
6
6
|
"description": "OPNet transaction library allows you to create and sign transactions for the OPNet network.",
|
|
7
7
|
"engines": {
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"docs": "typedoc --out docs --exclude 'src/tests/*.ts' --tsconfig tsconfig.json --readme README.md --name OPNet --plugin typedoc-material-theme --themeColor '#cb9820' --exclude src/tests/test.ts --exclude src/index.ts src"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@babel/core": "^7.27.
|
|
67
|
+
"@babel/core": "^7.27.3",
|
|
68
68
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
69
|
-
"@babel/plugin-transform-runtime": "^7.27.
|
|
69
|
+
"@babel/plugin-transform-runtime": "^7.27.3",
|
|
70
70
|
"@babel/preset-env": "^7.27.2",
|
|
71
71
|
"@babel/preset-flow": "^7.27.1",
|
|
72
72
|
"@babel/preset-react": "^7.27.1",
|
|
73
73
|
"@babel/preset-typescript": "^7.27.1",
|
|
74
|
-
"@types/node": "^22.15.
|
|
74
|
+
"@types/node": "^22.15.26",
|
|
75
75
|
"@types/sha.js": "^2.4.4",
|
|
76
76
|
"eslint": "^9.27.0",
|
|
77
77
|
"gulp": "^5.0.0",
|
|
@@ -83,13 +83,13 @@
|
|
|
83
83
|
"stream-browserify": "^3.0.0",
|
|
84
84
|
"stream-http": "^3.2.0",
|
|
85
85
|
"typedoc": "^0.28.5",
|
|
86
|
-
"typescript-eslint": "^8.
|
|
86
|
+
"typescript-eslint": "^8.33.0",
|
|
87
87
|
"webpack-cli": "^6.0.1"
|
|
88
88
|
},
|
|
89
89
|
"dependencies": {
|
|
90
90
|
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
|
91
91
|
"@bitcoinerlab/secp256k1": "^1.1.1",
|
|
92
|
-
"@btc-vision/bitcoin": "^6.4.
|
|
92
|
+
"@btc-vision/bitcoin": "^6.4.5",
|
|
93
93
|
"@btc-vision/bitcoin-rpc": "^1.0.1",
|
|
94
94
|
"@btc-vision/logger": "^1.0.6",
|
|
95
95
|
"@eslint/js": "^9.27.0",
|
|
@@ -2,6 +2,9 @@ import { crypto, Network, networks, opcodes, script } from '@btc-vision/bitcoin'
|
|
|
2
2
|
import { Generator } from '../Generator.js';
|
|
3
3
|
import { Feature, Features } from '../Features.js';
|
|
4
4
|
|
|
5
|
+
export const OPNET_DEPLOYMENT_VERSION = 0x00;
|
|
6
|
+
export const versionBuffer = Buffer.from([OPNET_DEPLOYMENT_VERSION]);
|
|
7
|
+
|
|
5
8
|
export class DeploymentGenerator extends Generator {
|
|
6
9
|
constructor(
|
|
7
10
|
senderPubKey: Buffer,
|
|
@@ -52,6 +55,7 @@ export class DeploymentGenerator extends Generator {
|
|
|
52
55
|
if (!this.contractSaltPubKey) throw new Error('Contract salt public key not set');
|
|
53
56
|
|
|
54
57
|
const dataChunks: Buffer[][] = this.splitBufferIntoChunks(contractBytecode);
|
|
58
|
+
|
|
55
59
|
const calldataChunks: Buffer[][] = calldata ? this.splitBufferIntoChunks(calldata) : [];
|
|
56
60
|
|
|
57
61
|
const featuresList: Features[] = [];
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
crypto as bitCrypto,
|
|
3
|
+
P2TRPayment,
|
|
3
4
|
Payment,
|
|
5
|
+
PaymentType,
|
|
4
6
|
Psbt,
|
|
5
7
|
PsbtInput,
|
|
6
8
|
Signer,
|
|
@@ -49,12 +51,12 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
|
|
|
49
51
|
* The target script redeem
|
|
50
52
|
* @private
|
|
51
53
|
*/
|
|
52
|
-
private targetScriptRedeem:
|
|
54
|
+
private targetScriptRedeem: P2TRPayment | null = null;
|
|
53
55
|
/**
|
|
54
56
|
* The left over funds script redeem
|
|
55
57
|
* @private
|
|
56
58
|
*/
|
|
57
|
-
private leftOverFundsScriptRedeem:
|
|
59
|
+
private leftOverFundsScriptRedeem: P2TRPayment | null = null;
|
|
58
60
|
/**
|
|
59
61
|
* The compiled target script
|
|
60
62
|
* @private
|
|
@@ -158,7 +160,7 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
|
|
|
158
160
|
this.to = this.getScriptAddress();
|
|
159
161
|
}
|
|
160
162
|
|
|
161
|
-
const selectedRedeem = this.contractSigner
|
|
163
|
+
const selectedRedeem: Payment | null = this.contractSigner
|
|
162
164
|
? this.targetScriptRedeem
|
|
163
165
|
: this.leftOverFundsScriptRedeem;
|
|
164
166
|
|
|
@@ -224,11 +226,12 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
|
|
|
224
226
|
* Get the tap output
|
|
225
227
|
* @protected
|
|
226
228
|
*/
|
|
227
|
-
protected override generateScriptAddress():
|
|
229
|
+
protected override generateScriptAddress(): P2TRPayment {
|
|
228
230
|
return {
|
|
229
231
|
internalPubkey: this.internalPubKeyToXOnly(),
|
|
230
232
|
network: this.network,
|
|
231
233
|
scriptTree: this.scriptTree,
|
|
234
|
+
name: PaymentType.P2TR,
|
|
232
235
|
};
|
|
233
236
|
}
|
|
234
237
|
|
|
@@ -236,7 +239,7 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
|
|
|
236
239
|
* Generate the tap data
|
|
237
240
|
* @protected
|
|
238
241
|
*/
|
|
239
|
-
protected override generateTapData():
|
|
242
|
+
protected override generateTapData(): P2TRPayment {
|
|
240
243
|
const selectedRedeem = this.contractSigner
|
|
241
244
|
? this.targetScriptRedeem
|
|
242
245
|
: this.leftOverFundsScriptRedeem;
|
|
@@ -254,6 +257,7 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
|
|
|
254
257
|
network: this.network,
|
|
255
258
|
scriptTree: this.scriptTree,
|
|
256
259
|
redeem: selectedRedeem,
|
|
260
|
+
name: PaymentType.P2TR,
|
|
257
261
|
};
|
|
258
262
|
}
|
|
259
263
|
|
|
@@ -329,13 +333,15 @@ export class CustomScriptTransaction extends TransactionBuilder<TransactionType.
|
|
|
329
333
|
*/
|
|
330
334
|
private generateRedeemScripts(): void {
|
|
331
335
|
this.targetScriptRedeem = {
|
|
332
|
-
|
|
336
|
+
name: PaymentType.P2TR,
|
|
337
|
+
//pubkeys: this.getPubKeys(),
|
|
333
338
|
output: this.compiledTargetScript,
|
|
334
339
|
redeemVersion: 192,
|
|
335
340
|
};
|
|
336
341
|
|
|
337
342
|
this.leftOverFundsScriptRedeem = {
|
|
338
|
-
|
|
343
|
+
name: PaymentType.P2TR,
|
|
344
|
+
//pubkeys: this.getPubKeys(),
|
|
339
345
|
output: this.getLeafScript(),
|
|
340
346
|
redeemVersion: 192,
|
|
341
347
|
};
|