@btc-vision/transaction 1.0.115 → 1.0.117
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/deterministic/AddressMap.d.ts +1 -0
- package/browser/deterministic/AddressSet.d.ts +2 -2
- package/browser/index.js +1 -1
- package/browser/keypair/Address.d.ts +1 -0
- package/browser/transaction/builders/MultiSignTransaction.d.ts +1 -2
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +1 -3
- package/browser/transaction/builders/TransactionBuilder.d.ts +2 -2
- package/browser/transaction/builders/UnwrapTransaction.d.ts +1 -2
- package/browser/transaction/interfaces/ITransactionParameters.d.ts +1 -1
- package/browser/transaction/interfaces/Tap.d.ts +20 -10
- package/browser/transaction/processor/PsbtTransaction.d.ts +1 -2
- package/browser/transaction/shared/TweakedTransaction.d.ts +2 -3
- package/browser/utils/types.d.ts +1 -0
- package/browser/verification/TapscriptVerificator.d.ts +1 -0
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/buffer/BinaryWriter.js +2 -2
- package/build/deterministic/AddressMap.d.ts +1 -0
- package/build/deterministic/AddressMap.js +5 -0
- package/build/deterministic/AddressSet.d.ts +2 -2
- package/build/deterministic/AddressSet.js +8 -3
- package/build/keypair/Address.d.ts +1 -0
- package/build/keypair/Address.js +27 -20
- package/build/keypair/AddressVerificator.js +1 -0
- package/build/keypair/Wallet.js +1 -1
- package/build/transaction/builders/DeploymentTransaction.js +3 -3
- package/build/transaction/builders/MultiSignTransaction.d.ts +1 -2
- package/build/transaction/builders/MultiSignTransaction.js +1 -1
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +1 -3
- package/build/transaction/builders/SharedInteractionTransaction.js +7 -43
- package/build/transaction/builders/TransactionBuilder.d.ts +2 -2
- package/build/transaction/builders/TransactionBuilder.js +1 -1
- package/build/transaction/builders/UnwrapTransaction.d.ts +1 -2
- package/build/transaction/builders/UnwrapTransaction.js +1 -1
- package/build/transaction/interfaces/ITransactionParameters.d.ts +1 -1
- package/build/transaction/interfaces/Tap.d.ts +20 -10
- package/build/transaction/processor/PsbtTransaction.d.ts +1 -2
- package/build/transaction/processor/PsbtTransaction.js +1 -1
- package/build/transaction/shared/TweakedTransaction.d.ts +2 -3
- package/build/transaction/shared/TweakedTransaction.js +1 -1
- package/build/utils/types.d.ts +1 -0
- package/build/verification/TapscriptVerificator.d.ts +1 -0
- package/build/verification/TapscriptVerificator.js +31 -0
- package/eslint.config.js +1 -0
- package/package.json +1 -1
- package/src/_version.ts +1 -1
- package/src/buffer/BinaryWriter.ts +2 -2
- package/src/deterministic/AddressMap.ts +6 -0
- package/src/deterministic/AddressSet.ts +10 -5
- package/src/keypair/Address.ts +37 -17
- package/src/keypair/AddressVerificator.ts +1 -0
- package/src/keypair/Wallet.ts +1 -1
- package/src/transaction/browser/extensions/UnisatSigner.ts +1 -2
- package/src/transaction/builders/CustomScriptTransaction.ts +1 -2
- package/src/transaction/builders/DeploymentTransaction.ts +4 -6
- package/src/transaction/builders/InteractionTransaction.ts +1 -1
- package/src/transaction/builders/MultiSignTransaction.ts +12 -3
- package/src/transaction/builders/SharedInteractionTransaction.ts +11 -68
- package/src/transaction/builders/TransactionBuilder.ts +12 -2
- package/src/transaction/builders/UnwrapSegwitTransaction.ts +2 -2
- package/src/transaction/builders/UnwrapTransaction.ts +9 -3
- package/src/transaction/builders/WrapTransaction.ts +2 -2
- package/src/transaction/interfaces/ITransactionParameters.ts +1 -1
- package/src/transaction/interfaces/Tap.ts +31 -12
- package/src/transaction/processor/PsbtTransaction.ts +9 -2
- package/src/transaction/shared/TweakedTransaction.ts +11 -3
- package/src/utils/types.ts +1 -0
- package/src/verification/TapscriptVerificator.ts +48 -0
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Network,
|
|
3
|
+
Psbt,
|
|
4
|
+
PsbtInputExtended,
|
|
5
|
+
PsbtOutputExtended,
|
|
6
|
+
Signer,
|
|
7
|
+
Transaction,
|
|
8
|
+
} from 'bitcoinjs-lib';
|
|
3
9
|
import { ITweakedTransactionData, TweakedTransaction } from '../shared/TweakedTransaction.js';
|
|
4
10
|
|
|
5
11
|
export interface PsbtTransactionData extends ITweakedTransactionData {
|
|
@@ -117,6 +123,7 @@ export class PsbtTransaction extends TweakedTransaction {
|
|
|
117
123
|
/**
|
|
118
124
|
* @description Add an input to the transaction
|
|
119
125
|
* @param input
|
|
126
|
+
* @param checkPartialSigs
|
|
120
127
|
*/
|
|
121
128
|
public addInput(input: PsbtInputExtended, checkPartialSigs: boolean = false): void {
|
|
122
129
|
this.transaction.addInput(input, checkPartialSigs);
|
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
import { Logger } from '@btc-vision/logger';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Network,
|
|
4
|
+
Payment,
|
|
5
|
+
payments,
|
|
6
|
+
Psbt,
|
|
7
|
+
PsbtInput,
|
|
8
|
+
PsbtInputExtended,
|
|
9
|
+
Signer,
|
|
10
|
+
Transaction,
|
|
11
|
+
} from 'bitcoinjs-lib';
|
|
3
12
|
import { TweakedSigner, TweakSettings } from '../../signer/TweakedSigner.js';
|
|
4
13
|
import { ECPairInterface } from 'ecpair';
|
|
5
14
|
import { toXOnly } from 'bitcoinjs-lib/src/psbt/bip371.js';
|
|
6
|
-
import { PsbtInput } from 'bip174/src/lib/interfaces.js';
|
|
7
15
|
import { UTXO } from '../../utxo/interfaces/IUTXO.js';
|
|
8
|
-
import {
|
|
16
|
+
import { TapLeafScript } from '../interfaces/Tap.js';
|
|
9
17
|
import { AddressVerificator } from '../../keypair/AddressVerificator.js';
|
|
10
18
|
import { ChainId } from '../../network/ChainId.js';
|
|
11
19
|
import { varuint } from 'bitcoinjs-lib/src/bufferutils.js';
|
package/src/utils/types.ts
CHANGED
|
@@ -8,6 +8,7 @@ export type BufferLike = Uint8Array | Buffer;
|
|
|
8
8
|
|
|
9
9
|
export type MemorySlotData<T> = T;
|
|
10
10
|
export type PointerStorage = DeterministicMap<MemorySlotPointer, MemorySlotData<bigint>>;
|
|
11
|
+
export type BlockchainStorage = DeterministicMap<string, PointerStorage>;
|
|
11
12
|
|
|
12
13
|
export type i32 = number;
|
|
13
14
|
export type u8 = number;
|
|
@@ -47,6 +47,54 @@ export class TapscriptVerificator {
|
|
|
47
47
|
return TapscriptVerificator.generateAddressFromScript(params, scriptTree);
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
public static verifyControlBlock(
|
|
51
|
+
params: ContractAddressVerificationParams,
|
|
52
|
+
controlBlock: Buffer,
|
|
53
|
+
): boolean {
|
|
54
|
+
const network = params.network || networks.bitcoin;
|
|
55
|
+
const scriptBuilder: DeploymentGenerator = new DeploymentGenerator(
|
|
56
|
+
params.deployerPubKey,
|
|
57
|
+
toXOnly(params.contractSaltPubKey),
|
|
58
|
+
network,
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
const compiledTargetScript: Buffer = scriptBuilder.compile(
|
|
62
|
+
params.bytecode,
|
|
63
|
+
params.originalSalt,
|
|
64
|
+
params.calldata,
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const scriptTree: Taptree = [
|
|
68
|
+
{
|
|
69
|
+
output: compiledTargetScript,
|
|
70
|
+
version: TapscriptVerificator.TAP_SCRIPT_VERSION,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
output: TransactionBuilder.LOCK_LEAF_SCRIPT,
|
|
74
|
+
version: TapscriptVerificator.TAP_SCRIPT_VERSION,
|
|
75
|
+
},
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
const tapData = payments.p2tr({
|
|
79
|
+
internalPubkey: toXOnly(params.deployerPubKey),
|
|
80
|
+
network: network,
|
|
81
|
+
scriptTree: scriptTree,
|
|
82
|
+
redeem: {
|
|
83
|
+
pubkeys: [params.deployerPubKey, params.contractSaltPubKey],
|
|
84
|
+
output: compiledTargetScript,
|
|
85
|
+
redeemVersion: TapscriptVerificator.TAP_SCRIPT_VERSION,
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const witness = tapData.witness;
|
|
90
|
+
if (!witness || witness.length === 0) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const requiredControlBlock: Buffer = witness[witness.length - 1];
|
|
95
|
+
return requiredControlBlock.equals(controlBlock);
|
|
96
|
+
}
|
|
97
|
+
|
|
50
98
|
public static getContractSeed(
|
|
51
99
|
deployerPubKey: Buffer,
|
|
52
100
|
bytecode: Buffer,
|