@btc-vision/transaction 1.7.28 → 1.7.29
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/btc-vision-bitcoin.js +1610 -1609
- package/browser/consensus/ConsensusConfig.d.ts +1 -5
- package/browser/consensus/IConsensusConfig.d.ts +6 -0
- package/browser/consensus/metadata/RoswellConsensus.d.ts +1 -1
- package/browser/epoch/interfaces/IChallengeSolution.d.ts +15 -1
- package/browser/generators/builders/CalldataGenerator.d.ts +2 -2
- package/browser/generators/builders/DeploymentGenerator.d.ts +2 -2
- package/browser/generators/builders/P2WDAGenerator.d.ts +2 -2
- package/browser/index.js +876 -1055
- package/browser/opnet.d.ts +7 -2
- package/browser/signer/AddressRotation.d.ts +2 -3
- package/browser/signer/IRotationSigner.d.ts +8 -0
- package/browser/transaction/TransactionFactory.d.ts +4 -27
- package/browser/transaction/browser/Web3Provider.d.ts +2 -25
- package/browser/transaction/builders/CancelTransaction.d.ts +1 -4
- package/browser/transaction/builders/ConsolidatedInteractionTransaction.d.ts +3 -3
- package/browser/transaction/builders/CustomScriptTransaction.d.ts +2 -8
- package/browser/transaction/builders/DeploymentTransaction.d.ts +3 -3
- package/browser/transaction/builders/InteractionTransactionP2WDA.d.ts +2 -2
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +3 -3
- package/browser/transaction/interfaces/ICancelTransactionParameters.d.ts +4 -0
- package/browser/transaction/interfaces/ICustomTransactionParameters.d.ts +8 -0
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +6 -6
- package/browser/transaction/interfaces/ITransactionResponses.d.ts +26 -0
- package/browser/transaction/interfaces/ITweakedTransactionData.d.ts +17 -0
- package/browser/transaction/interfaces/IWeb3ProviderTypes.d.ts +24 -0
- package/browser/transaction/shared/TweakedTransaction.d.ts +2 -14
- package/browser/transaction/utils/WitnessUtils.d.ts +1 -0
- package/browser/utxo/OPNetLimitedProvider.d.ts +1 -1
- package/browser/utxo/interfaces/IUTXO.d.ts +2 -2
- package/browser/vendors.js +90 -90
- package/browser/verification/TapscriptVerificator.d.ts +2 -2
- package/build/consensus/ConsensusConfig.d.ts +1 -5
- package/build/consensus/IConsensusConfig.d.ts +6 -0
- package/build/consensus/IConsensusConfig.js +1 -0
- package/build/consensus/metadata/RoswellConsensus.d.ts +1 -1
- package/build/epoch/interfaces/IChallengeSolution.d.ts +15 -1
- package/build/epoch/validator/EpochValidator.js +35 -3
- package/build/generators/builders/CalldataGenerator.d.ts +2 -2
- package/build/generators/builders/DeploymentGenerator.d.ts +2 -2
- package/build/generators/builders/P2WDAGenerator.d.ts +2 -2
- package/build/opnet.d.ts +7 -2
- package/build/opnet.js +7 -2
- package/build/signer/AddressRotation.d.ts +2 -3
- package/build/signer/IRotationSigner.d.ts +8 -0
- package/build/signer/IRotationSigner.js +1 -0
- package/build/transaction/TransactionFactory.d.ts +4 -27
- package/build/transaction/TransactionFactory.js +1 -1
- package/build/transaction/browser/Web3Provider.d.ts +2 -25
- package/build/transaction/builders/CancelTransaction.d.ts +1 -4
- package/build/transaction/builders/ConsolidatedInteractionTransaction.d.ts +3 -3
- package/build/transaction/builders/CustomScriptTransaction.d.ts +2 -8
- package/build/transaction/builders/DeploymentTransaction.d.ts +3 -3
- package/build/transaction/builders/InteractionTransactionP2WDA.d.ts +2 -2
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +3 -3
- package/build/transaction/builders/TransactionBuilder.js +3 -21
- package/build/transaction/interfaces/ICancelTransactionParameters.d.ts +4 -0
- package/build/transaction/interfaces/ICancelTransactionParameters.js +1 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.d.ts +8 -0
- package/build/transaction/interfaces/ICustomTransactionParameters.js +1 -0
- package/build/transaction/interfaces/ITransactionParameters.d.ts +6 -6
- package/build/transaction/interfaces/ITransactionResponses.d.ts +26 -0
- package/build/transaction/interfaces/ITransactionResponses.js +1 -0
- package/build/transaction/interfaces/ITweakedTransactionData.d.ts +17 -0
- package/build/transaction/interfaces/ITweakedTransactionData.js +1 -0
- package/build/transaction/interfaces/IWeb3ProviderTypes.d.ts +24 -0
- package/build/transaction/interfaces/IWeb3ProviderTypes.js +1 -0
- package/build/transaction/shared/TweakedTransaction.d.ts +2 -14
- package/build/transaction/shared/TweakedTransaction.js +3 -3
- package/build/transaction/utils/WitnessUtils.d.ts +1 -0
- package/build/transaction/utils/WitnessUtils.js +23 -0
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/utxo/OPNetLimitedProvider.d.ts +1 -1
- package/build/utxo/OPNetLimitedProvider.js +1 -1
- package/build/utxo/interfaces/IUTXO.d.ts +2 -2
- package/build/verification/TapscriptVerificator.d.ts +2 -2
- package/package.json +6 -3
- package/src/consensus/ConsensusConfig.ts +1 -28
- package/src/consensus/IConsensusConfig.ts +29 -0
- package/src/consensus/metadata/RoswellConsensus.ts +1 -1
- package/src/epoch/interfaces/IChallengeSolution.ts +13 -1
- package/src/epoch/validator/EpochValidator.ts +54 -3
- package/src/generators/builders/CalldataGenerator.ts +3 -3
- package/src/generators/builders/DeploymentGenerator.ts +3 -3
- package/src/generators/builders/P2WDAGenerator.ts +2 -2
- package/src/keypair/MessageSigner.ts +1 -1
- package/src/opnet.ts +7 -4
- package/src/signer/AddressRotation.ts +3 -4
- package/src/signer/IRotationSigner.ts +35 -0
- package/src/transaction/TransactionFactory.ts +14 -38
- package/src/transaction/browser/Web3Provider.ts +14 -78
- package/src/transaction/builders/CancelTransaction.ts +2 -11
- package/src/transaction/builders/ConsolidatedInteractionTransaction.ts +3 -3
- package/src/transaction/builders/CustomScriptTransaction.ts +1 -15
- package/src/transaction/builders/DeploymentTransaction.ts +3 -3
- package/src/transaction/builders/InteractionTransactionP2WDA.ts +3 -3
- package/src/transaction/builders/SharedInteractionTransaction.ts +3 -3
- package/src/transaction/builders/TransactionBuilder.ts +2 -28
- package/src/transaction/interfaces/ICancelTransactionParameters.ts +8 -0
- package/src/transaction/interfaces/ICustomTransactionParameters.ts +15 -0
- package/src/transaction/interfaces/ITransactionParameters.ts +6 -6
- package/src/transaction/interfaces/ITransactionResponses.ts +29 -0
- package/src/transaction/interfaces/ITweakedTransactionData.ts +24 -0
- package/src/transaction/interfaces/IWeb3ProviderTypes.ts +74 -0
- package/src/transaction/offline/TransactionReconstructor.ts +1 -1
- package/src/transaction/shared/TweakedTransaction.ts +6 -30
- package/src/transaction/utils/WitnessUtils.ts +36 -0
- package/src/utxo/OPNetLimitedProvider.ts +3 -1
- package/src/utxo/interfaces/IUTXO.ts +2 -2
- package/src/verification/TapscriptVerificator.ts +2 -2
- package/browser/metadata/tokens.d.ts +0 -39
- package/browser/transaction/processor/PsbtTransaction.d.ts +0 -25
- package/build/metadata/tokens.d.ts +0 -39
- package/build/metadata/tokens.js +0 -100
- package/build/transaction/processor/PsbtTransaction.d.ts +0 -25
- package/build/transaction/processor/PsbtTransaction.js +0 -80
- package/src/metadata/tokens.ts +0 -139
- package/src/transaction/processor/PsbtTransaction.ts +0 -179
|
@@ -6,32 +6,18 @@ import {
|
|
|
6
6
|
Psbt,
|
|
7
7
|
PsbtInput,
|
|
8
8
|
Signer,
|
|
9
|
-
Stack,
|
|
10
9
|
Taptree,
|
|
11
10
|
toXOnly,
|
|
12
11
|
} from '@btc-vision/bitcoin';
|
|
13
12
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
14
13
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
15
|
-
import { SharedInteractionParameters } from '../interfaces/ITransactionParameters.js';
|
|
16
14
|
import { TransactionBuilder } from './TransactionBuilder.js';
|
|
17
15
|
import { CustomGenerator } from '../../generators/builders/CustomGenerator.js';
|
|
18
16
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
19
17
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
20
18
|
import { AddressGenerator } from '../../generators/AddressGenerator.js';
|
|
21
19
|
import { ECPairInterface } from 'ecpair';
|
|
22
|
-
|
|
23
|
-
export interface ICustomTransactionParameters extends Omit<
|
|
24
|
-
SharedInteractionParameters,
|
|
25
|
-
'challenge'
|
|
26
|
-
> {
|
|
27
|
-
script: (Buffer | Stack)[];
|
|
28
|
-
witnesses: Buffer[];
|
|
29
|
-
|
|
30
|
-
/** optional Taproot annex payload (without the 0x50 prefix) */
|
|
31
|
-
annex?: Buffer;
|
|
32
|
-
|
|
33
|
-
to: string;
|
|
34
|
-
}
|
|
20
|
+
import { ICustomTransactionParameters } from '../interfaces/ICustomTransactionParameters.js';
|
|
35
21
|
|
|
36
22
|
/**
|
|
37
23
|
* Class for interaction transactions
|
|
@@ -24,7 +24,7 @@ import { ECPairInterface } from 'ecpair';
|
|
|
24
24
|
import { Address } from '../../keypair/Address.js';
|
|
25
25
|
import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
|
|
26
26
|
import { TimeLockGenerator } from '../mineable/TimelockGenerator.js';
|
|
27
|
-
import {
|
|
27
|
+
import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
|
|
28
28
|
import { Feature, FeaturePriority, Features } from '../../generators/Features.js';
|
|
29
29
|
import { IP2WSHAddress } from '../mineable/IP2WSHAddress.js';
|
|
30
30
|
|
|
@@ -33,7 +33,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
|
|
|
33
33
|
|
|
34
34
|
public type: TransactionType.DEPLOYMENT = TransactionType.DEPLOYMENT;
|
|
35
35
|
|
|
36
|
-
protected readonly challenge:
|
|
36
|
+
protected readonly challenge: IChallengeSolution;
|
|
37
37
|
protected readonly epochChallenge: IP2WSHAddress;
|
|
38
38
|
|
|
39
39
|
/**
|
|
@@ -210,7 +210,7 @@ export class DeploymentTransaction extends TransactionBuilder<TransactionType.DE
|
|
|
210
210
|
* Get the contract bytecode
|
|
211
211
|
* @returns {Buffer} The contract bytecode
|
|
212
212
|
*/
|
|
213
|
-
public getChallenge():
|
|
213
|
+
public getChallenge(): IChallengeSolution {
|
|
214
214
|
return this.challenge;
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -9,7 +9,7 @@ import { P2WDAGenerator } from '../../generators/builders/P2WDAGenerator.js';
|
|
|
9
9
|
import { Feature, FeaturePriority, Features } from '../../generators/Features.js';
|
|
10
10
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
11
11
|
import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
12
|
-
import {
|
|
12
|
+
import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
|
|
13
13
|
import { ECPairInterface } from 'ecpair';
|
|
14
14
|
import { P2WDADetector } from '../../p2wda/P2WDADetector.js';
|
|
15
15
|
import { IP2WSHAddress } from '../mineable/IP2WSHAddress.js';
|
|
@@ -36,7 +36,7 @@ export class InteractionTransactionP2WDA extends TransactionBuilder<TransactionT
|
|
|
36
36
|
private readonly contractAddress: string;
|
|
37
37
|
private readonly contractSecret: Buffer;
|
|
38
38
|
private readonly calldata: Buffer;
|
|
39
|
-
private readonly challenge:
|
|
39
|
+
private readonly challenge: IChallengeSolution;
|
|
40
40
|
private readonly randomBytes: Buffer;
|
|
41
41
|
private p2wdaGenerator: P2WDAGenerator;
|
|
42
42
|
private scriptSigner: ECPairInterface;
|
|
@@ -131,7 +131,7 @@ export class InteractionTransactionP2WDA extends TransactionBuilder<TransactionT
|
|
|
131
131
|
/**
|
|
132
132
|
* Get the challenge (for compatibility if needed elsewhere)
|
|
133
133
|
*/
|
|
134
|
-
public getChallenge():
|
|
134
|
+
public getChallenge(): IChallengeSolution {
|
|
135
135
|
return this.challenge;
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -9,7 +9,7 @@ import { EcKeyPair } from '../../keypair/EcKeyPair.js';
|
|
|
9
9
|
import { BitcoinUtils } from '../../utils/BitcoinUtils.js';
|
|
10
10
|
import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
|
|
11
11
|
import { TimeLockGenerator } from '../mineable/TimelockGenerator.js';
|
|
12
|
-
import {
|
|
12
|
+
import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
|
|
13
13
|
import { IP2WSHAddress } from '../mineable/IP2WSHAddress.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -33,7 +33,7 @@ export abstract class SharedInteractionTransaction<
|
|
|
33
33
|
protected abstract readonly compiledTargetScript: Buffer;
|
|
34
34
|
protected abstract readonly scriptTree: Taptree;
|
|
35
35
|
|
|
36
|
-
protected readonly challenge:
|
|
36
|
+
protected readonly challenge: IChallengeSolution;
|
|
37
37
|
protected readonly epochChallenge: IP2WSHAddress;
|
|
38
38
|
|
|
39
39
|
protected calldataGenerator: CalldataGenerator;
|
|
@@ -118,7 +118,7 @@ export abstract class SharedInteractionTransaction<
|
|
|
118
118
|
/**
|
|
119
119
|
* Get the preimage
|
|
120
120
|
*/
|
|
121
|
-
public getChallenge():
|
|
121
|
+
public getChallenge(): IChallengeSolution {
|
|
122
122
|
return this.challenge;
|
|
123
123
|
}
|
|
124
124
|
|
|
@@ -10,8 +10,8 @@ import bitcoin, {
|
|
|
10
10
|
Signer,
|
|
11
11
|
toXOnly,
|
|
12
12
|
Transaction,
|
|
13
|
-
varuint,
|
|
14
13
|
} from '@btc-vision/bitcoin';
|
|
14
|
+
import { witnessStackToScriptWitness } from '../utils/WitnessUtils.js';
|
|
15
15
|
import * as ecc from '@bitcoinerlab/secp256k1';
|
|
16
16
|
import { UpdateInput } from '../interfaces/Tap.js';
|
|
17
17
|
import { TransactionType } from '../enums/TransactionType.js';
|
|
@@ -232,33 +232,7 @@ export abstract class TransactionBuilder<T extends TransactionType> extends Twea
|
|
|
232
232
|
* @returns {Buffer}
|
|
233
233
|
*/
|
|
234
234
|
public static witnessStackToScriptWitness(witness: Buffer[]): Buffer {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
function writeSlice(slice: Buffer) {
|
|
238
|
-
buffer = Buffer.concat([buffer, Buffer.from(slice)]);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function writeVarInt(i: number) {
|
|
242
|
-
const currentLen = buffer.length;
|
|
243
|
-
const varintLen = varuint.encodingLength(i);
|
|
244
|
-
|
|
245
|
-
buffer = Buffer.concat([buffer, Buffer.allocUnsafe(varintLen)]);
|
|
246
|
-
varuint.encode(i, buffer, currentLen);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function writeVarSlice(slice: Buffer) {
|
|
250
|
-
writeVarInt(slice.length);
|
|
251
|
-
writeSlice(slice);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
function writeVector(vector: Buffer[]) {
|
|
255
|
-
writeVarInt(vector.length);
|
|
256
|
-
vector.forEach(writeVarSlice);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
writeVector(witness);
|
|
260
|
-
|
|
261
|
-
return buffer;
|
|
235
|
+
return witnessStackToScriptWitness(witness);
|
|
262
236
|
}
|
|
263
237
|
|
|
264
238
|
public addOPReturn(buffer: Buffer): void {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Stack } from '@btc-vision/bitcoin';
|
|
2
|
+
import { SharedInteractionParameters } from './ITransactionParameters.js';
|
|
3
|
+
|
|
4
|
+
export interface ICustomTransactionParameters extends Omit<
|
|
5
|
+
SharedInteractionParameters,
|
|
6
|
+
'challenge'
|
|
7
|
+
> {
|
|
8
|
+
script: (Buffer | Stack)[];
|
|
9
|
+
witnesses: Buffer[];
|
|
10
|
+
|
|
11
|
+
/** optional Taproot annex payload (without the 0x50 prefix) */
|
|
12
|
+
annex?: Buffer;
|
|
13
|
+
|
|
14
|
+
to: string;
|
|
15
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
2
|
-
import { ITweakedTransactionData } from '
|
|
2
|
+
import { ITweakedTransactionData } from './ITweakedTransactionData.js';
|
|
3
3
|
import { ChainId } from '../../network/ChainId.js';
|
|
4
4
|
import { PsbtOutputExtended } from '@btc-vision/bitcoin';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
5
|
+
import { IChallengeSolution } from '../../epoch/interfaces/IChallengeSolution.js';
|
|
6
|
+
import { AddressRotationConfigBase } from '../../signer/IRotationSigner.js';
|
|
7
7
|
|
|
8
8
|
export interface LoadedStorage {
|
|
9
9
|
[key: string]: string[];
|
|
@@ -49,7 +49,7 @@ export interface ITransactionParameters extends ITweakedTransactionData {
|
|
|
49
49
|
* When enabled, allows different signers to sign different UTXOs based on their addresses.
|
|
50
50
|
* This supports proper Bitcoin privacy practices where each UTXO has its own key.
|
|
51
51
|
*/
|
|
52
|
-
readonly addressRotation?:
|
|
52
|
+
readonly addressRotation?: AddressRotationConfigBase;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
export interface IFundingTransactionParameters extends ITransactionParameters {
|
|
@@ -62,7 +62,7 @@ export interface SharedInteractionParameters extends ITransactionParameters {
|
|
|
62
62
|
calldata?: Buffer;
|
|
63
63
|
disableAutoRefund?: boolean;
|
|
64
64
|
|
|
65
|
-
readonly challenge:
|
|
65
|
+
readonly challenge: IChallengeSolution;
|
|
66
66
|
readonly randomBytes?: Buffer;
|
|
67
67
|
|
|
68
68
|
readonly loadedStorage?: LoadedStorage;
|
|
@@ -81,5 +81,5 @@ export interface IDeploymentParameters extends Omit<ITransactionParameters, 'to'
|
|
|
81
81
|
readonly calldata?: Buffer;
|
|
82
82
|
|
|
83
83
|
readonly randomBytes?: Buffer;
|
|
84
|
-
readonly challenge:
|
|
84
|
+
readonly challenge: IChallengeSolution;
|
|
85
85
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RawChallenge } from '../../epoch/interfaces/IChallengeSolution.js';
|
|
2
|
+
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
3
|
+
|
|
4
|
+
export interface DeploymentResult {
|
|
5
|
+
readonly transaction: [string, string];
|
|
6
|
+
readonly contractAddress: string;
|
|
7
|
+
readonly contractPubKey: string;
|
|
8
|
+
readonly challenge: RawChallenge;
|
|
9
|
+
readonly utxos: UTXO[];
|
|
10
|
+
readonly inputUtxos: UTXO[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface InteractionResponse {
|
|
14
|
+
readonly fundingTransaction: string | null;
|
|
15
|
+
readonly interactionTransaction: string;
|
|
16
|
+
readonly estimatedFees: bigint;
|
|
17
|
+
readonly nextUTXOs: UTXO[];
|
|
18
|
+
readonly fundingUTXOs: UTXO[];
|
|
19
|
+
readonly fundingInputUtxos: UTXO[];
|
|
20
|
+
readonly challenge: RawChallenge;
|
|
21
|
+
readonly interactionAddress: string | null;
|
|
22
|
+
readonly compiledTargetScript: string | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface CancelledTransaction {
|
|
26
|
+
readonly transaction: string;
|
|
27
|
+
readonly nextUTXOs: UTXO[];
|
|
28
|
+
readonly inputUtxos: UTXO[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Network, Signer } from '@btc-vision/bitcoin';
|
|
2
|
+
import { ECPairInterface } from 'ecpair';
|
|
3
|
+
import { QuantumBIP32Interface } from '@btc-vision/bip32';
|
|
4
|
+
import { ChainId } from '../../network/ChainId.js';
|
|
5
|
+
import { AddressRotationConfigBase } from '../../signer/IRotationSigner.js';
|
|
6
|
+
|
|
7
|
+
export type SupportedTransactionVersion = 1 | 2 | 3;
|
|
8
|
+
|
|
9
|
+
export interface ITweakedTransactionData {
|
|
10
|
+
readonly mldsaSigner: QuantumBIP32Interface | null;
|
|
11
|
+
readonly signer: Signer | ECPairInterface;
|
|
12
|
+
readonly network: Network;
|
|
13
|
+
readonly chainId?: ChainId;
|
|
14
|
+
readonly nonWitnessUtxo?: Buffer;
|
|
15
|
+
readonly noSignatures?: boolean;
|
|
16
|
+
readonly unlockScript?: Buffer[];
|
|
17
|
+
readonly txVersion?: SupportedTransactionVersion;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Address rotation configuration for per-UTXO signing.
|
|
21
|
+
* When enabled, each UTXO can be signed by a different signer.
|
|
22
|
+
*/
|
|
23
|
+
readonly addressRotation?: AddressRotationConfigBase;
|
|
24
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { IDeploymentParameters, IInteractionParameters } from './ITransactionParameters.js';
|
|
2
|
+
import { ICustomTransactionParameters } from './ICustomTransactionParameters.js';
|
|
3
|
+
import { ICancelTransactionParameters } from './ICancelTransactionParameters.js';
|
|
4
|
+
import { MLDSASecurityLevel } from '@btc-vision/bip32';
|
|
5
|
+
|
|
6
|
+
export type InteractionParametersWithoutSigner = Omit<
|
|
7
|
+
IInteractionParameters,
|
|
8
|
+
'signer' | 'challenge' | 'mldsaSigner'
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
export type IDeploymentParametersWithoutSigner = Omit<
|
|
12
|
+
IDeploymentParameters,
|
|
13
|
+
'signer' | 'network' | 'challenge' | 'mldsaSigner'
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type ICustomTransactionWithoutSigner = Omit<
|
|
17
|
+
ICustomTransactionParameters,
|
|
18
|
+
'signer' | 'challenge' | 'mldsaSigner'
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export type ICancelTransactionParametersWithoutSigner = Omit<
|
|
22
|
+
ICancelTransactionParameters,
|
|
23
|
+
'signer' | 'challenge' | 'network' | 'mldsaSigner'
|
|
24
|
+
>;
|
|
25
|
+
|
|
26
|
+
export interface BroadcastTransactionOptions {
|
|
27
|
+
raw: string;
|
|
28
|
+
psbt: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface BroadcastedTransaction {
|
|
32
|
+
/** Whether the transaction was successfully broadcasted. */
|
|
33
|
+
readonly success: boolean;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The result of the broadcasted transaction.
|
|
37
|
+
*/
|
|
38
|
+
readonly result?: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The error message if the transaction was not successfully broadcasted.
|
|
42
|
+
*/
|
|
43
|
+
readonly error?: string;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The number of peers that the transaction was broadcasted to.
|
|
47
|
+
*/
|
|
48
|
+
readonly peers?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* ML-DSA signature result
|
|
53
|
+
*/
|
|
54
|
+
export interface MLDSASignature {
|
|
55
|
+
/**
|
|
56
|
+
* The ML-DSA signature in hex format
|
|
57
|
+
*/
|
|
58
|
+
readonly signature: string;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The ML-DSA public key used for signing in hex format
|
|
62
|
+
*/
|
|
63
|
+
readonly publicKey: string;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The security level used (44, 65, or 87)
|
|
67
|
+
*/
|
|
68
|
+
readonly securityLevel: MLDSASecurityLevel;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The message hash that was signed
|
|
72
|
+
*/
|
|
73
|
+
readonly messageHash: string;
|
|
74
|
+
}
|
|
@@ -33,7 +33,7 @@ import {
|
|
|
33
33
|
IInteractionParameters,
|
|
34
34
|
ITransactionParameters,
|
|
35
35
|
} from '../interfaces/ITransactionParameters.js';
|
|
36
|
-
import { SupportedTransactionVersion } from '../
|
|
36
|
+
import { SupportedTransactionVersion } from '../interfaces/ITweakedTransactionData.js';
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
39
|
* Options for reconstructing a transaction from serialized state
|
|
@@ -31,38 +31,15 @@ import { TweakedSigner, TweakSettings } from '../../signer/TweakedSigner.js';
|
|
|
31
31
|
import { ECPairInterface } from 'ecpair';
|
|
32
32
|
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
33
33
|
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
34
|
-
import { ChainId } from '../../network/ChainId.js';
|
|
35
34
|
import { UnisatSigner } from '../browser/extensions/UnisatSigner.js';
|
|
36
|
-
import {
|
|
37
|
-
|
|
38
|
-
isTaprootInput,
|
|
39
|
-
pubkeyInScript,
|
|
40
|
-
} from '../../signer/SignerUtils.js';
|
|
41
|
-
import { TransactionBuilder } from '../builders/TransactionBuilder.js';
|
|
35
|
+
import { canSignNonTaprootInput, isTaprootInput, pubkeyInScript, } from '../../signer/SignerUtils.js';
|
|
36
|
+
import { witnessStackToScriptWitness } from '../utils/WitnessUtils.js';
|
|
42
37
|
import { Buffer } from 'buffer';
|
|
43
38
|
import { P2WDADetector } from '../../p2wda/P2WDADetector.js';
|
|
44
39
|
import { QuantumBIP32Interface } from '@btc-vision/bip32';
|
|
45
40
|
import { MessageSigner } from '../../keypair/MessageSigner.js';
|
|
46
|
-
import {
|
|
47
|
-
|
|
48
|
-
export type SupportedTransactionVersion = 1 | 2 | 3;
|
|
49
|
-
|
|
50
|
-
export interface ITweakedTransactionData {
|
|
51
|
-
readonly mldsaSigner: QuantumBIP32Interface | null;
|
|
52
|
-
readonly signer: Signer | ECPairInterface | UnisatSigner;
|
|
53
|
-
readonly network: Network;
|
|
54
|
-
readonly chainId?: ChainId;
|
|
55
|
-
readonly nonWitnessUtxo?: Buffer;
|
|
56
|
-
readonly noSignatures?: boolean;
|
|
57
|
-
readonly unlockScript?: Buffer[];
|
|
58
|
-
readonly txVersion?: SupportedTransactionVersion;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Address rotation configuration for per-UTXO signing.
|
|
62
|
-
* When enabled, each UTXO can be signed by a different signer.
|
|
63
|
-
*/
|
|
64
|
-
readonly addressRotation?: AddressRotationConfig;
|
|
65
|
-
}
|
|
41
|
+
import { RotationSigner, SignerMap } from '../../signer/AddressRotation.js';
|
|
42
|
+
import { ITweakedTransactionData, SupportedTransactionVersion, } from '../interfaces/ITweakedTransactionData.js';
|
|
66
43
|
|
|
67
44
|
/**
|
|
68
45
|
* The transaction sequence
|
|
@@ -1146,8 +1123,7 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
1146
1123
|
const witnessStack = [input.partialSig[0].signature, input.witnessScript];
|
|
1147
1124
|
return {
|
|
1148
1125
|
finalScriptSig: undefined,
|
|
1149
|
-
finalScriptWitness:
|
|
1150
|
-
TransactionBuilder.witnessStackToScriptWitness(witnessStack),
|
|
1126
|
+
finalScriptWitness: witnessStackToScriptWitness(witnessStack),
|
|
1151
1127
|
};
|
|
1152
1128
|
}
|
|
1153
1129
|
|
|
@@ -1191,7 +1167,7 @@ export abstract class TweakedTransaction extends Logger {
|
|
|
1191
1167
|
|
|
1192
1168
|
return {
|
|
1193
1169
|
finalScriptSig: undefined,
|
|
1194
|
-
finalScriptWitness:
|
|
1170
|
+
finalScriptWitness: witnessStackToScriptWitness(witnessStack),
|
|
1195
1171
|
};
|
|
1196
1172
|
}
|
|
1197
1173
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { varuint } from '@btc-vision/bitcoin';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Convert witness stack to script witness buffer
|
|
5
|
+
* @param {Buffer[]} witness - The witness stack
|
|
6
|
+
* @returns {Buffer}
|
|
7
|
+
*/
|
|
8
|
+
export function witnessStackToScriptWitness(witness: Buffer[]): Buffer {
|
|
9
|
+
let buffer = Buffer.allocUnsafe(0);
|
|
10
|
+
|
|
11
|
+
function writeSlice(slice: Buffer) {
|
|
12
|
+
buffer = Buffer.concat([buffer, Buffer.from(slice)]);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function writeVarInt(i: number) {
|
|
16
|
+
const currentLen = buffer.length;
|
|
17
|
+
const varintLen = varuint.encodingLength(i);
|
|
18
|
+
|
|
19
|
+
buffer = Buffer.concat([buffer, Buffer.allocUnsafe(varintLen)]);
|
|
20
|
+
varuint.encode(i, buffer, currentLen);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function writeVarSlice(slice: Buffer) {
|
|
24
|
+
writeVarInt(slice.length);
|
|
25
|
+
writeSlice(slice);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function writeVector(vector: Buffer[]) {
|
|
29
|
+
writeVarInt(vector.length);
|
|
30
|
+
vector.forEach(writeVarSlice);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
writeVector(witness);
|
|
34
|
+
|
|
35
|
+
return buffer;
|
|
36
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { Network } from '@btc-vision/bitcoin';
|
|
2
|
-
import { IFundingTransactionParameters
|
|
2
|
+
import { IFundingTransactionParameters } from '../transaction/interfaces/ITransactionParameters.js';
|
|
3
|
+
import { TransactionFactory } from '../transaction/TransactionFactory.js';
|
|
4
|
+
import { Wallet } from '../keypair/Wallet.js';
|
|
3
5
|
import { BroadcastResponse } from './interfaces/BroadcastResponse.js';
|
|
4
6
|
import {
|
|
5
7
|
FetchUTXOParams,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ScriptPubKey } from '@btc-vision/bitcoin-rpc';
|
|
2
|
-
import {
|
|
2
|
+
import { RotationSignerBase } from '../../signer/IRotationSigner.js';
|
|
3
3
|
|
|
4
4
|
export interface UTXO {
|
|
5
5
|
readonly transactionId: string;
|
|
@@ -16,7 +16,7 @@ export interface UTXO {
|
|
|
16
16
|
* Used in address rotation mode where each UTXO may have its own signer.
|
|
17
17
|
* If not provided, the signer will be resolved from the signerMap or the default signer.
|
|
18
18
|
*/
|
|
19
|
-
signer?:
|
|
19
|
+
signer?: RotationSignerBase;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface FetchUTXOParams {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
toXOnly,
|
|
11
11
|
} from '@btc-vision/bitcoin';
|
|
12
12
|
import { DeploymentGenerator } from '../generators/builders/DeploymentGenerator.js';
|
|
13
|
-
import {
|
|
13
|
+
import { IChallengeSolution } from '../epoch/interfaces/IChallengeSolution.js';
|
|
14
14
|
import { Feature, Features } from '../generators/Features.js';
|
|
15
15
|
|
|
16
16
|
export interface ContractAddressVerificationParams {
|
|
@@ -18,7 +18,7 @@ export interface ContractAddressVerificationParams {
|
|
|
18
18
|
readonly contractSaltPubKey: Buffer;
|
|
19
19
|
readonly originalSalt: Buffer;
|
|
20
20
|
readonly bytecode: Buffer;
|
|
21
|
-
readonly challenge:
|
|
21
|
+
readonly challenge: IChallengeSolution;
|
|
22
22
|
readonly priorityFee: bigint;
|
|
23
23
|
readonly features: Feature<Features>[];
|
|
24
24
|
readonly calldata?: Buffer;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ChainId } from '../network/ChainId.js';
|
|
2
|
-
import { Address } from '../keypair/Address.js';
|
|
3
|
-
export declare const FACTORY_ADDRESS_REGTEST: Address;
|
|
4
|
-
export declare const POOL_ADDRESS_REGTEST: Address;
|
|
5
|
-
export declare const WBTC_ADDRESS_REGTEST: Address;
|
|
6
|
-
export declare const MOTO_ADDRESS_REGTEST: Address;
|
|
7
|
-
export declare const ROUTER_ADDRESS_REGTEST: Address;
|
|
8
|
-
export declare const FACTORY_ADDRESS_TESTNET: Address;
|
|
9
|
-
export declare const POOL_ADDRESS_TESTNET: Address;
|
|
10
|
-
export declare const WBTC_ADDRESS_TESTNET: Address;
|
|
11
|
-
export declare const MOTO_ADDRESS_TESTNET: Address;
|
|
12
|
-
export declare const ROUTER_ADDRESS_TESTNET: Address;
|
|
13
|
-
export declare const FACTORY_ADDRESS_FRACTAL: Address;
|
|
14
|
-
export declare const POOL_ADDRESS_FRACTAL: Address;
|
|
15
|
-
export declare const WBTC_ADDRESS_FRACTAL: Address;
|
|
16
|
-
export declare const MOTO_ADDRESS_FRACTAL: Address;
|
|
17
|
-
export declare const ROUTER_ADDRESS_FRACTAL: Address;
|
|
18
|
-
export declare enum OPNetNetwork {
|
|
19
|
-
Mainnet = "mainnet",
|
|
20
|
-
Testnet = "testnet",
|
|
21
|
-
Regtest = "regtest"
|
|
22
|
-
}
|
|
23
|
-
export interface OPNetTokenMetadata {
|
|
24
|
-
readonly factory: Address;
|
|
25
|
-
readonly pool: Address;
|
|
26
|
-
readonly wbtc: Address;
|
|
27
|
-
readonly moto: Address;
|
|
28
|
-
readonly router: Address;
|
|
29
|
-
}
|
|
30
|
-
export declare class OPNetTokenAddressManager {
|
|
31
|
-
private readonly metadata;
|
|
32
|
-
getFactoryAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
33
|
-
getPoolAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
34
|
-
getWBTCAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
35
|
-
getMOTOAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
36
|
-
getRouterAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
37
|
-
getAddresses(network: OPNetNetwork, chainId: ChainId): OPNetTokenMetadata;
|
|
38
|
-
}
|
|
39
|
-
export declare const OPNetMetadata: OPNetTokenAddressManager;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Network, Psbt, PsbtInputExtended, PsbtOutputExtended, Signer, Transaction } from '../../../node_modules/@btc-vision/bitcoin/build/index.js';
|
|
2
|
-
import { ITweakedTransactionData, TweakedTransaction } from '../shared/TweakedTransaction.js';
|
|
3
|
-
export interface PsbtTransactionData extends ITweakedTransactionData {
|
|
4
|
-
readonly psbt: Psbt;
|
|
5
|
-
readonly signer: Signer;
|
|
6
|
-
readonly network: Network;
|
|
7
|
-
}
|
|
8
|
-
export type FromBase64Params = Omit<PsbtTransactionData, 'psbt'>;
|
|
9
|
-
export declare class PsbtTransaction extends TweakedTransaction {
|
|
10
|
-
readonly logColor: string;
|
|
11
|
-
feesAddition: bigint;
|
|
12
|
-
protected readonly transaction: Psbt;
|
|
13
|
-
protected readonly sighashTypes: number[] | undefined;
|
|
14
|
-
constructor(data: PsbtTransactionData);
|
|
15
|
-
static fromBase64(data: string, params: FromBase64Params): PsbtTransaction;
|
|
16
|
-
static fromHex(data: string, params: FromBase64Params): PsbtTransaction;
|
|
17
|
-
static from(params: FromBase64Params): PsbtTransaction;
|
|
18
|
-
extractTransaction(): Transaction;
|
|
19
|
-
final(): string;
|
|
20
|
-
toHex(): string;
|
|
21
|
-
addInput(input: PsbtInputExtended, checkPartialSigs?: boolean): void;
|
|
22
|
-
addOutput(output: PsbtOutputExtended): void;
|
|
23
|
-
attemptFinalizeInputs(n?: number): boolean;
|
|
24
|
-
getPSBT(): Psbt;
|
|
25
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { ChainId } from '../network/ChainId.js';
|
|
2
|
-
import { Address } from '../keypair/Address.js';
|
|
3
|
-
export declare const FACTORY_ADDRESS_REGTEST: Address;
|
|
4
|
-
export declare const POOL_ADDRESS_REGTEST: Address;
|
|
5
|
-
export declare const WBTC_ADDRESS_REGTEST: Address;
|
|
6
|
-
export declare const MOTO_ADDRESS_REGTEST: Address;
|
|
7
|
-
export declare const ROUTER_ADDRESS_REGTEST: Address;
|
|
8
|
-
export declare const FACTORY_ADDRESS_TESTNET: Address;
|
|
9
|
-
export declare const POOL_ADDRESS_TESTNET: Address;
|
|
10
|
-
export declare const WBTC_ADDRESS_TESTNET: Address;
|
|
11
|
-
export declare const MOTO_ADDRESS_TESTNET: Address;
|
|
12
|
-
export declare const ROUTER_ADDRESS_TESTNET: Address;
|
|
13
|
-
export declare const FACTORY_ADDRESS_FRACTAL: Address;
|
|
14
|
-
export declare const POOL_ADDRESS_FRACTAL: Address;
|
|
15
|
-
export declare const WBTC_ADDRESS_FRACTAL: Address;
|
|
16
|
-
export declare const MOTO_ADDRESS_FRACTAL: Address;
|
|
17
|
-
export declare const ROUTER_ADDRESS_FRACTAL: Address;
|
|
18
|
-
export declare enum OPNetNetwork {
|
|
19
|
-
Mainnet = "mainnet",
|
|
20
|
-
Testnet = "testnet",
|
|
21
|
-
Regtest = "regtest"
|
|
22
|
-
}
|
|
23
|
-
export interface OPNetTokenMetadata {
|
|
24
|
-
readonly factory: Address;
|
|
25
|
-
readonly pool: Address;
|
|
26
|
-
readonly wbtc: Address;
|
|
27
|
-
readonly moto: Address;
|
|
28
|
-
readonly router: Address;
|
|
29
|
-
}
|
|
30
|
-
export declare class OPNetTokenAddressManager {
|
|
31
|
-
private readonly metadata;
|
|
32
|
-
getFactoryAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
33
|
-
getPoolAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
34
|
-
getWBTCAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
35
|
-
getMOTOAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
36
|
-
getRouterAddress(network: OPNetNetwork, chainId: ChainId): Address;
|
|
37
|
-
getAddresses(network: OPNetNetwork, chainId: ChainId): OPNetTokenMetadata;
|
|
38
|
-
}
|
|
39
|
-
export declare const OPNetMetadata: OPNetTokenAddressManager;
|