@btc-vision/bitcoin 7.0.0-alpha.1 → 7.0.0-alpha.3
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/README.md +334 -161
- package/browser/address.d.ts +5 -1
- package/browser/address.d.ts.map +1 -1
- package/browser/branded.d.ts +3 -14
- package/browser/branded.d.ts.map +1 -1
- package/browser/ecc/context.d.ts +22 -21
- package/browser/ecc/context.d.ts.map +1 -1
- package/browser/ecc/index.d.ts +1 -1
- package/browser/ecc/index.d.ts.map +1 -1
- package/browser/ecc/types.d.ts +10 -123
- package/browser/ecc/types.d.ts.map +1 -1
- package/browser/index.d.ts +3 -2
- package/browser/index.d.ts.map +1 -1
- package/browser/index.js +6465 -4692
- package/browser/opcodes.d.ts +11 -0
- package/browser/opcodes.d.ts.map +1 -1
- package/browser/payments/p2tr.d.ts.map +1 -1
- package/browser/psbt/PsbtCache.d.ts +54 -0
- package/browser/psbt/PsbtCache.d.ts.map +1 -0
- package/browser/psbt/PsbtFinalizer.d.ts +21 -0
- package/browser/psbt/PsbtFinalizer.d.ts.map +1 -0
- package/browser/psbt/PsbtSigner.d.ts +32 -0
- package/browser/psbt/PsbtSigner.d.ts.map +1 -0
- package/browser/psbt/PsbtTransaction.d.ts +25 -0
- package/browser/psbt/PsbtTransaction.d.ts.map +1 -0
- package/browser/psbt/types.d.ts +4 -70
- package/browser/psbt/types.d.ts.map +1 -1
- package/browser/psbt/validation.d.ts +1 -1
- package/browser/psbt/validation.d.ts.map +1 -1
- package/browser/psbt.d.ts +26 -40
- package/browser/psbt.d.ts.map +1 -1
- package/browser/script.d.ts.map +1 -1
- package/browser/transaction.d.ts +4 -4
- package/browser/transaction.d.ts.map +1 -1
- package/browser/types.d.ts +5 -3
- package/browser/types.d.ts.map +1 -1
- package/browser/workers/index.d.ts +3 -50
- package/browser/workers/index.d.ts.map +1 -1
- package/browser/workers/index.node.d.ts +24 -0
- package/browser/workers/index.node.d.ts.map +1 -0
- package/build/address.d.ts +5 -1
- package/build/address.d.ts.map +1 -1
- package/build/address.js +29 -17
- package/build/address.js.map +1 -1
- package/build/branded.d.ts +3 -14
- package/build/branded.d.ts.map +1 -1
- package/build/branded.js +0 -5
- package/build/branded.js.map +1 -1
- package/build/ecc/context.d.ts +22 -21
- package/build/ecc/context.d.ts.map +1 -1
- package/build/ecc/context.js +23 -95
- package/build/ecc/context.js.map +1 -1
- package/build/ecc/index.d.ts +1 -1
- package/build/ecc/index.d.ts.map +1 -1
- package/build/ecc/types.d.ts +7 -126
- package/build/ecc/types.d.ts.map +1 -1
- package/build/ecc/types.js +4 -1
- package/build/ecc/types.js.map +1 -1
- package/build/index.d.ts +3 -2
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/opcodes.d.ts +11 -0
- package/build/opcodes.d.ts.map +1 -1
- package/build/opcodes.js +19 -4
- package/build/opcodes.js.map +1 -1
- package/build/payments/p2tr.d.ts.map +1 -1
- package/build/payments/p2tr.js +2 -3
- package/build/payments/p2tr.js.map +1 -1
- package/build/psbt/PsbtCache.d.ts +54 -0
- package/build/psbt/PsbtCache.d.ts.map +1 -0
- package/build/psbt/PsbtCache.js +249 -0
- package/build/psbt/PsbtCache.js.map +1 -0
- package/build/psbt/PsbtFinalizer.d.ts +21 -0
- package/build/psbt/PsbtFinalizer.d.ts.map +1 -0
- package/build/psbt/PsbtFinalizer.js +157 -0
- package/build/psbt/PsbtFinalizer.js.map +1 -0
- package/build/psbt/PsbtSigner.d.ts +32 -0
- package/build/psbt/PsbtSigner.d.ts.map +1 -0
- package/build/psbt/PsbtSigner.js +192 -0
- package/build/psbt/PsbtSigner.js.map +1 -0
- package/build/psbt/PsbtTransaction.d.ts +25 -0
- package/build/psbt/PsbtTransaction.d.ts.map +1 -0
- package/build/psbt/PsbtTransaction.js +61 -0
- package/build/psbt/PsbtTransaction.js.map +1 -0
- package/build/psbt/types.d.ts +4 -70
- package/build/psbt/types.d.ts.map +1 -1
- package/build/psbt/validation.d.ts +1 -1
- package/build/psbt/validation.d.ts.map +1 -1
- package/build/psbt.d.ts +26 -40
- package/build/psbt.d.ts.map +1 -1
- package/build/psbt.js +177 -799
- package/build/psbt.js.map +1 -1
- package/build/script.d.ts.map +1 -1
- package/build/script.js +2 -2
- package/build/script.js.map +1 -1
- package/build/transaction.d.ts +4 -4
- package/build/transaction.d.ts.map +1 -1
- package/build/transaction.js +5 -4
- package/build/transaction.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/build/types.d.ts +5 -3
- package/build/types.d.ts.map +1 -1
- package/build/types.js +9 -0
- package/build/types.js.map +1 -1
- package/build/workers/WorkerSigningPool.js +1 -1
- package/build/workers/WorkerSigningPool.js.map +1 -1
- package/build/workers/index.d.ts +3 -3
- package/build/workers/index.d.ts.map +1 -1
- package/build/workers/index.js +0 -3
- package/build/workers/index.js.map +1 -1
- package/build/workers/index.node.d.ts +24 -0
- package/build/workers/index.node.d.ts.map +1 -0
- package/build/workers/index.node.js +26 -0
- package/build/workers/index.node.js.map +1 -0
- package/package.json +27 -8
- package/src/address.ts +41 -18
- package/src/branded.ts +15 -13
- package/src/ecc/context.ts +30 -133
- package/src/ecc/index.ts +2 -2
- package/src/ecc/types.ts +7 -138
- package/src/index.ts +36 -2
- package/src/opcodes.ts +21 -4
- package/src/payments/p2tr.ts +2 -2
- package/src/psbt/PsbtCache.ts +325 -0
- package/src/psbt/PsbtFinalizer.ts +213 -0
- package/src/psbt/PsbtSigner.ts +302 -0
- package/src/psbt/PsbtTransaction.ts +82 -0
- package/src/psbt/types.ts +4 -86
- package/src/psbt/validation.ts +1 -1
- package/src/psbt.ts +348 -1197
- package/src/script.ts +2 -2
- package/src/transaction.ts +9 -8
- package/src/types.ts +14 -1
- package/src/workers/WorkerSigningPool.ts +1 -1
- package/src/workers/index.node.ts +27 -0
- package/src/workers/index.ts +7 -9
- package/test/address.spec.ts +2 -2
- package/test/bitcoin.core.spec.ts +5 -2
- package/test/browser/payments.spec.ts +151 -0
- package/test/browser/psbt.spec.ts +1510 -0
- package/test/browser/script.spec.ts +223 -0
- package/test/browser/setup.ts +13 -0
- package/test/browser/workers-signing.spec.ts +537 -0
- package/test/crypto.spec.ts +2 -2
- package/test/fixtures/core/base58_encode_decode.json +12 -48
- package/test/fixtures/core/base58_keys_invalid.json +50 -150
- package/test/fixtures/core/sighash.json +1 -3
- package/test/fixtures/core/tx_valid.json +133 -501
- package/test/fixtures/embed.json +3 -11
- package/test/fixtures/p2ms.json +21 -91
- package/test/fixtures/p2pk.json +5 -24
- package/test/fixtures/p2pkh.json +7 -36
- package/test/fixtures/p2sh.json +8 -54
- package/test/fixtures/p2tr.json +2 -6
- package/test/fixtures/p2wpkh.json +7 -36
- package/test/fixtures/p2wsh.json +14 -59
- package/test/fixtures/psbt.json +2 -6
- package/test/fixtures/script.json +12 -48
- package/test/integration/addresses.spec.ts +11 -5
- package/test/integration/bip32.spec.ts +1 -1
- package/test/integration/cltv.spec.ts +10 -6
- package/test/integration/csv.spec.ts +10 -9
- package/test/integration/payments.spec.ts +8 -4
- package/test/integration/taproot.spec.ts +26 -6
- package/test/integration/transactions.spec.ts +22 -8
- package/test/payments.spec.ts +1 -1
- package/test/payments.utils.ts +1 -1
- package/test/psbt.spec.ts +250 -64
- package/test/script_signature.spec.ts +1 -1
- package/test/transaction.spec.ts +18 -5
- package/test/tsconfig.json +6 -20
- package/test/workers-pool.spec.ts +22 -23
- package/test/workers-signing.spec.ts +7 -3
- package/test/workers.spec.ts +6 -7
- package/typedoc.json +11 -1
- package/vitest.config.browser.ts +68 -0
- package/browser/ecpair.d.ts +0 -99
- package/src/ecpair.d.ts +0 -99
- package/test/taproot-cache.spec.ts +0 -694
package/src/psbt/types.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import type { Psbt as PsbtBase, PsbtGlobal, PsbtInput, PsbtOutput } from 'bip174';
|
|
7
7
|
import type { Network } from '../networks.js';
|
|
8
8
|
import type { TaprootHashCache, Transaction } from '../transaction.js';
|
|
9
|
-
import type { Bytes32, PublicKey, Satoshi,
|
|
9
|
+
import type { Bytes32, MessageHash, PublicKey, Satoshi, Script } from '../types.js';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Transaction input interface for PSBT.
|
|
@@ -45,7 +45,7 @@ export interface PsbtTxOutput extends TransactionOutput {
|
|
|
45
45
|
*/
|
|
46
46
|
export type ValidateSigFunction = (
|
|
47
47
|
pubkey: PublicKey,
|
|
48
|
-
msghash:
|
|
48
|
+
msghash: MessageHash,
|
|
49
49
|
signature: Uint8Array,
|
|
50
50
|
) => boolean;
|
|
51
51
|
|
|
@@ -102,89 +102,7 @@ export interface PsbtOutputExtendedScript extends PsbtOutput {
|
|
|
102
102
|
readonly value: Satoshi;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
* Base interface for HD signers.
|
|
107
|
-
*/
|
|
108
|
-
interface HDSignerBase {
|
|
109
|
-
/**
|
|
110
|
-
* DER format compressed publicKey Uint8Array
|
|
111
|
-
*/
|
|
112
|
-
readonly publicKey: PublicKey;
|
|
113
|
-
/**
|
|
114
|
-
* The first 4 bytes of the sha256-ripemd160 of the publicKey
|
|
115
|
-
*/
|
|
116
|
-
readonly fingerprint: Uint8Array;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* HD signer interface for synchronous signing.
|
|
121
|
-
*/
|
|
122
|
-
export interface HDSigner extends HDSignerBase {
|
|
123
|
-
/**
|
|
124
|
-
* The path string must match /^m(\/\d+'?)+$/
|
|
125
|
-
* ex. m/44'/0'/0'/1/23 levels with ' must be hard derivations
|
|
126
|
-
*/
|
|
127
|
-
derivePath(path: string): HDSigner;
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Input hash (the "message digest") for the signature algorithm
|
|
131
|
-
* Return a 64 byte signature (32 byte r and 32 byte s in that order)
|
|
132
|
-
*/
|
|
133
|
-
sign(hash: Bytes32): Uint8Array;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* HD signer interface for asynchronous signing.
|
|
138
|
-
*/
|
|
139
|
-
export interface HDSignerAsync extends HDSignerBase {
|
|
140
|
-
derivePath(path: string): HDSignerAsync;
|
|
141
|
-
|
|
142
|
-
sign(hash: Bytes32): Promise<Uint8Array>;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Alternative signer interface with lowR support.
|
|
147
|
-
*/
|
|
148
|
-
export interface SignerAlternative {
|
|
149
|
-
readonly publicKey: PublicKey;
|
|
150
|
-
readonly lowR: boolean;
|
|
151
|
-
|
|
152
|
-
sign(hash: Bytes32, lowR?: boolean): Signature;
|
|
153
|
-
|
|
154
|
-
verify(hash: Bytes32, signature: Signature): boolean;
|
|
155
|
-
|
|
156
|
-
signSchnorr(hash: Bytes32): SchnorrSignature;
|
|
157
|
-
|
|
158
|
-
verifySchnorr(hash: Bytes32, signature: SchnorrSignature): boolean;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Basic signer interface for synchronous signing.
|
|
163
|
-
*/
|
|
164
|
-
export interface Signer {
|
|
165
|
-
readonly publicKey: PublicKey;
|
|
166
|
-
readonly network?: Network | undefined;
|
|
167
|
-
|
|
168
|
-
sign(hash: Bytes32, lowR?: boolean): Signature;
|
|
169
|
-
|
|
170
|
-
signSchnorr?(hash: Bytes32): SchnorrSignature;
|
|
171
|
-
|
|
172
|
-
getPublicKey?(): PublicKey;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Basic signer interface for asynchronous signing.
|
|
177
|
-
*/
|
|
178
|
-
export interface SignerAsync {
|
|
179
|
-
readonly publicKey: PublicKey;
|
|
180
|
-
readonly network?: Network | undefined;
|
|
181
|
-
|
|
182
|
-
sign(hash: Bytes32, lowR?: boolean): Promise<Signature>;
|
|
183
|
-
|
|
184
|
-
signSchnorr?(hash: Bytes32): Promise<SchnorrSignature>;
|
|
185
|
-
|
|
186
|
-
getPublicKey?(): PublicKey;
|
|
187
|
-
}
|
|
105
|
+
export type { Signer, SignerAsync, HDSigner, HDSignerAsync } from '@btc-vision/ecpair';
|
|
188
106
|
|
|
189
107
|
/**
|
|
190
108
|
* Minimal key pair interface for checking Taproot hashes.
|
|
@@ -199,7 +117,7 @@ export interface TaprootHashCheckSigner {
|
|
|
199
117
|
/**
|
|
200
118
|
* Internal PSBT cache for computed values.
|
|
201
119
|
*/
|
|
202
|
-
export interface
|
|
120
|
+
export interface PsbtCacheInterface {
|
|
203
121
|
nonWitnessUtxoTxCache: Transaction[];
|
|
204
122
|
nonWitnessUtxoBufCache: Uint8Array[];
|
|
205
123
|
txInCache: TxInCacheMap;
|
package/src/psbt/validation.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { checkTaprootInputForSigs, isTaprootInput } from './bip371.js';
|
|
|
11
11
|
import { checkInputForSig, pubkeyInScript } from './psbtutils.js';
|
|
12
12
|
import * as bscript from '../script.js';
|
|
13
13
|
import type { Transaction } from '../transaction.js';
|
|
14
|
-
import type { PsbtCache } from './types.js';
|
|
14
|
+
import type { PsbtCacheInterface as PsbtCache } from './types.js';
|
|
15
15
|
import type { PublicKey, Script } from '../types.js';
|
|
16
16
|
|
|
17
17
|
/**
|