@bsv/sdk 1.1.29 → 1.1.32
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/dist/cjs/package.json +1 -1
- package/dist/cjs/src/primitives/Schnorr.js +92 -0
- package/dist/cjs/src/primitives/Schnorr.js.map +1 -0
- package/dist/cjs/src/primitives/index.js +3 -1
- package/dist/cjs/src/primitives/index.js.map +1 -1
- package/dist/cjs/src/totp/totp.js +1 -1
- package/dist/cjs/src/totp/totp.js.map +1 -1
- package/dist/cjs/src/transaction/Beef.js +292 -155
- package/dist/cjs/src/transaction/Beef.js.map +1 -1
- package/dist/cjs/src/transaction/BeefParty.js +46 -26
- package/dist/cjs/src/transaction/BeefParty.js.map +1 -1
- package/dist/cjs/src/transaction/BeefTx.js +31 -16
- package/dist/cjs/src/transaction/BeefTx.js.map +1 -1
- package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
- package/dist/cjs/src/transaction/Transaction.js +12 -6
- package/dist/cjs/src/transaction/Transaction.js.map +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/src/primitives/Schnorr.js +87 -0
- package/dist/esm/src/primitives/Schnorr.js.map +1 -0
- package/dist/esm/src/primitives/index.js +1 -0
- package/dist/esm/src/primitives/index.js.map +1 -1
- package/dist/esm/src/totp/totp.js +1 -1
- package/dist/esm/src/totp/totp.js.map +1 -1
- package/dist/esm/src/transaction/Beef.js +294 -157
- package/dist/esm/src/transaction/Beef.js.map +1 -1
- package/dist/esm/src/transaction/BeefParty.js +47 -27
- package/dist/esm/src/transaction/BeefParty.js.map +1 -1
- package/dist/esm/src/transaction/BeefTx.js +35 -20
- package/dist/esm/src/transaction/BeefTx.js.map +1 -1
- package/dist/esm/src/transaction/MerklePath.js.map +1 -1
- package/dist/esm/src/transaction/Transaction.js +12 -6
- package/dist/esm/src/transaction/Transaction.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/types/src/primitives/Schnorr.d.ts +65 -0
- package/dist/types/src/primitives/Schnorr.d.ts.map +1 -0
- package/dist/types/src/primitives/index.d.ts +1 -0
- package/dist/types/src/primitives/index.d.ts.map +1 -1
- package/dist/types/src/transaction/Beef.d.ts +131 -90
- package/dist/types/src/transaction/Beef.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefParty.d.ts +34 -23
- package/dist/types/src/transaction/BeefParty.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefTx.d.ts +11 -6
- package/dist/types/src/transaction/BeefTx.d.ts.map +1 -1
- package/dist/types/src/transaction/MerklePath.d.ts.map +1 -1
- package/dist/types/src/transaction/Transaction.d.ts +8 -2
- package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/dist/umd/bundle.js +1 -1
- package/docs/primitives.md +120 -9
- package/docs/transaction.md +141 -9
- package/package.json +1 -1
- package/src/primitives/Schnorr.ts +95 -0
- package/src/primitives/__tests/Schnorr.test.ts +272 -0
- package/src/primitives/index.ts +1 -0
- package/src/totp/totp.ts +1 -1
- package/src/transaction/Beef.ts +493 -378
- package/src/transaction/BeefParty.ts +71 -58
- package/src/transaction/BeefTx.ts +133 -143
- package/src/transaction/MerklePath.ts +11 -11
- package/src/transaction/Transaction.ts +42 -36
- package/src/transaction/__tests/Beef.test.ts +55 -10
|
@@ -1,144 +1,185 @@
|
|
|
1
|
-
import MerklePath from
|
|
2
|
-
import Transaction from
|
|
3
|
-
import ChainTracker from
|
|
4
|
-
import BeefTx from
|
|
5
|
-
import { Reader } from
|
|
1
|
+
import MerklePath from './MerklePath.js';
|
|
2
|
+
import Transaction from './Transaction.js';
|
|
3
|
+
import ChainTracker from './ChainTracker.js';
|
|
4
|
+
import BeefTx from './BeefTx.js';
|
|
5
|
+
import { Reader } from '../primitives/utils.js';
|
|
6
6
|
export declare const BEEF_MAGIC = 4022206465;
|
|
7
7
|
export declare const BEEF_MAGIC_V2 = 4022206466;
|
|
8
8
|
export declare const BEEF_MAGIC_TXID_ONLY_EXTENSION = 4022206465;
|
|
9
|
+
export declare const ATOMIC_BEEF = 16843009;
|
|
9
10
|
export type BeefVersion = undefined | 'V1' | 'V2';
|
|
10
11
|
export declare class Beef {
|
|
11
12
|
bumps: MerklePath[];
|
|
12
13
|
txs: BeefTx[];
|
|
13
14
|
version: BeefVersion;
|
|
15
|
+
atomicTxid: string | undefined;
|
|
14
16
|
constructor(version?: BeefVersion);
|
|
15
17
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
* BEEF_MAGIC is the original V1 version.
|
|
19
|
+
* BEEF_MAGIC_V2 includes support for txidOnly transactions in serialized beefs.
|
|
20
|
+
* @returns version magic value based on current contents and constructor version parameter.
|
|
21
|
+
*/
|
|
20
22
|
get magic(): number;
|
|
21
23
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
* @param txid of `beefTx` to find
|
|
25
|
+
* @returns `BeefTx` in `txs` with `txid`.
|
|
26
|
+
*/
|
|
25
27
|
findTxid(txid: string): BeefTx | undefined;
|
|
26
28
|
/**
|
|
27
|
-
*
|
|
28
|
-
* @param bump
|
|
29
|
-
* @returns index of merged bump
|
|
29
|
+
* @returns `MerklePath` with level zero hash equal to txid or undefined.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
findBump(txid: string): MerklePath | undefined;
|
|
32
32
|
/**
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* Checks that a transaction with the same txid hasn't already been merged.
|
|
33
|
+
* Finds a Transaction in this `Beef`
|
|
34
|
+
* and adds any missing input SourceTransactions from this `Beef`.
|
|
36
35
|
*
|
|
37
|
-
*
|
|
36
|
+
* The result is suitable for signing.
|
|
38
37
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @
|
|
41
|
-
* @returns txid of rawTx
|
|
38
|
+
* @param txid The id of the target transaction.
|
|
39
|
+
* @returns Transaction with all available input `SourceTransaction`s from this Beef.
|
|
42
40
|
*/
|
|
43
|
-
|
|
41
|
+
findTransactionForSigning(txid: string): Transaction | undefined;
|
|
44
42
|
/**
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* Replaces existing transaction with same txid.
|
|
43
|
+
* Builds the proof tree rooted at a specific `Transaction`.
|
|
48
44
|
*
|
|
49
|
-
*
|
|
45
|
+
* To succeed, the Beef must contain all the required transaction and merkle path data.
|
|
50
46
|
*
|
|
51
|
-
* @param
|
|
52
|
-
* @returns
|
|
47
|
+
* @param txid The id of the target transaction.
|
|
48
|
+
* @returns Transaction with input `SourceTransaction` and `MerklePath` populated from this Beef.
|
|
53
49
|
*/
|
|
50
|
+
findAtomicTransaction(txid: string): Transaction | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Merge a MerklePath that is assumed to be fully valid.
|
|
53
|
+
* @param bump
|
|
54
|
+
* @returns index of merged bump
|
|
55
|
+
*/
|
|
56
|
+
mergeBump(bump: MerklePath): number;
|
|
57
|
+
/**
|
|
58
|
+
* Merge a serialized transaction.
|
|
59
|
+
*
|
|
60
|
+
* Checks that a transaction with the same txid hasn't already been merged.
|
|
61
|
+
*
|
|
62
|
+
* Replaces existing transaction with same txid.
|
|
63
|
+
*
|
|
64
|
+
* @param rawTx
|
|
65
|
+
* @param bumpIndex Optional. If a number, must be valid index into bumps array.
|
|
66
|
+
* @returns txid of rawTx
|
|
67
|
+
*/
|
|
68
|
+
mergeRawTx(rawTx: number[], bumpIndex?: number): BeefTx;
|
|
69
|
+
/**
|
|
70
|
+
* Merge a `Transaction` and any referenced `merklePath` and `sourceTransaction`, recursifely.
|
|
71
|
+
*
|
|
72
|
+
* Replaces existing transaction with same txid.
|
|
73
|
+
*
|
|
74
|
+
* Attempts to match an existing bump to the new transaction.
|
|
75
|
+
*
|
|
76
|
+
* @param tx
|
|
77
|
+
* @returns txid of tx
|
|
78
|
+
*/
|
|
54
79
|
mergeTransaction(tx: Transaction): BeefTx;
|
|
55
80
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
81
|
+
* Removes an existing transaction from the BEEF, given its TXID
|
|
82
|
+
* @param txid TXID of the transaction to remove
|
|
83
|
+
*/
|
|
59
84
|
removeExistingTxid(txid: string): void;
|
|
60
85
|
mergeTxidOnly(txid: string): BeefTx;
|
|
61
86
|
mergeBeefTx(btx: BeefTx): BeefTx;
|
|
62
87
|
mergeBeef(beef: number[] | Beef): void;
|
|
63
88
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
* Sorts `txs` and checks structural validity of beef.
|
|
90
|
+
*
|
|
91
|
+
* Does NOT verify merkle roots.
|
|
92
|
+
*
|
|
93
|
+
* Validity requirements:
|
|
94
|
+
* 1. No 'known' txids, unless `allowTxidOnly` is true.
|
|
95
|
+
* 2. All transactions have bumps or their inputs chain back to bumps (or are known).
|
|
96
|
+
* 3. Order of transactions satisfies dependencies before dependents.
|
|
97
|
+
* 4. No transactions with duplicate txids.
|
|
98
|
+
*
|
|
99
|
+
* @param allowTxidOnly optional. If true, transaction txid only is assumed valid
|
|
100
|
+
*/
|
|
76
101
|
isValid(allowTxidOnly?: boolean): boolean;
|
|
77
102
|
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
103
|
+
* Sorts `txs` and confirms validity of transaction data contained in beef
|
|
104
|
+
* by validating structure of this beef and confirming computed merkle roots
|
|
105
|
+
* using `chainTracker`.
|
|
106
|
+
*
|
|
107
|
+
* Validity requirements:
|
|
108
|
+
* 1. No 'known' txids, unless `allowTxidOnly` is true.
|
|
109
|
+
* 2. All transactions have bumps or their inputs chain back to bumps (or are known).
|
|
110
|
+
* 3. Order of transactions satisfies dependencies before dependents.
|
|
111
|
+
* 4. No transactions with duplicate txids.
|
|
112
|
+
*
|
|
113
|
+
* @param chainTracker Used to verify computed merkle path roots for all bump txids.
|
|
114
|
+
* @param allowTxidOnly optional. If true, transaction txid is assumed valid
|
|
115
|
+
*/
|
|
91
116
|
verify(chainTracker: ChainTracker, allowTxidOnly?: boolean): Promise<boolean>;
|
|
92
117
|
private verifyValid;
|
|
93
118
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
119
|
+
* Returns a binary array representing the serialized BEEF
|
|
120
|
+
* @returns A binary array representing the BEEF
|
|
121
|
+
*/
|
|
97
122
|
toBinary(): number[];
|
|
98
123
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
124
|
+
* Returns a hex string representing the serialized BEEF
|
|
125
|
+
* @returns A hex string representing the BEEF
|
|
126
|
+
*/
|
|
102
127
|
toHex(): string;
|
|
103
128
|
static fromReader(br: Reader): Beef;
|
|
104
129
|
/**
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
130
|
+
* Constructs an instance of the Beef class based on the provided binary array
|
|
131
|
+
* @param bin The binary array from which to construct BEEF
|
|
132
|
+
* @returns An instance of the Beef class constructed from the binary data
|
|
133
|
+
*/
|
|
109
134
|
static fromBinary(bin: number[]): Beef;
|
|
110
135
|
/**
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
136
|
+
* Constructs an instance of the Beef class based on the provided string
|
|
137
|
+
* @param s The string value from which to construct BEEF
|
|
138
|
+
* @param enc The encoding of the string value from which BEEF should be constructed
|
|
139
|
+
* @returns An instance of the Beef class constructed from the string
|
|
140
|
+
*/
|
|
116
141
|
static fromString(s: string, enc?: 'hex' | 'utf8' | 'base64'): Beef;
|
|
117
142
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
143
|
+
* Try to validate newTx.bumpIndex by looking for an existing bump
|
|
144
|
+
* that proves newTx.txid
|
|
145
|
+
*
|
|
146
|
+
* @param newTx A new `BeefTx` that has been added to this.txs
|
|
147
|
+
* @returns true if a bump was found, false otherwise
|
|
148
|
+
*/
|
|
124
149
|
private tryToValidateBumpIndex;
|
|
125
150
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
151
|
+
* Sort the `txs` by input txid dependency order:
|
|
152
|
+
* - Oldest Tx Anchored by Path
|
|
153
|
+
* - Newer Txs depending on Older parents
|
|
154
|
+
* - Newest Tx
|
|
155
|
+
*
|
|
156
|
+
* with proof (MerklePath) last, longest chain of dependencies first
|
|
157
|
+
*
|
|
158
|
+
* @returns `{ missingInputs, notValid, valid, withMissingInputs }`
|
|
159
|
+
*/
|
|
160
|
+
sortTxs(): {
|
|
161
|
+
missingInputs: string[];
|
|
162
|
+
notValid: string[];
|
|
163
|
+
valid: string[];
|
|
164
|
+
withMissingInputs: string[];
|
|
165
|
+
txidOnly: string[];
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* @returns a shallow copy of this beef
|
|
169
|
+
*/
|
|
133
170
|
clone(): Beef;
|
|
134
171
|
/**
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
172
|
+
* Ensure that all the txids in `knownTxids` are txidOnly
|
|
173
|
+
* @param knownTxids
|
|
174
|
+
*/
|
|
138
175
|
trimKnownTxids(knownTxids: string[]): void;
|
|
139
176
|
/**
|
|
140
|
-
* @returns
|
|
177
|
+
* @returns array of transaction txids that either have a proof or whose inputs chain back to a proven transaction.
|
|
141
178
|
*/
|
|
179
|
+
getValidTxids(): string[];
|
|
180
|
+
/**
|
|
181
|
+
* @returns Summary of `Beef` contents as multi-line string.
|
|
182
|
+
*/
|
|
142
183
|
toLogString(): string;
|
|
143
184
|
}
|
|
144
185
|
export default Beef;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Beef.d.ts","sourceRoot":"","sources":["../../../../src/transaction/Beef.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"Beef.d.ts","sourceRoot":"","sources":["../../../../src/transaction/Beef.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,iBAAiB,CAAA;AACxC,OAAO,WAAW,MAAM,kBAAkB,CAAA;AAC1C,OAAO,YAAY,MAAM,mBAAmB,CAAA;AAC5C,OAAO,MAAM,MAAM,aAAa,CAAA;AAChC,OAAO,EAAE,MAAM,EAA0B,MAAM,wBAAwB,CAAA;AAEvE,eAAO,MAAM,UAAU,aAAa,CAAA;AACpC,eAAO,MAAM,aAAa,aAAa,CAAA;AACvC,eAAO,MAAM,8BAA8B,aAAa,CAAA;AACxD,eAAO,MAAM,WAAW,WAAa,CAAA;AAErC,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,IAAI,GAAG,IAAI,CAAA;AAuDjD,qBAAa,IAAI;IACf,KAAK,EAAE,UAAU,EAAE,CAAK;IACxB,GAAG,EAAE,MAAM,EAAE,CAAK;IAClB,OAAO,EAAE,WAAW,CAAY;IAChC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAY;gBAE7B,OAAO,CAAC,EAAE,WAAW;IAIlC;;;;SAIK;IACL,IAAI,KAAK,IAAK,MAAM,CASnB;IAED;;;SAGK;IACL,QAAQ,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3C;;OAEG;IACH,QAAQ,CAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI/C;;;;;;;;OAQG;IACH,yBAAyB,CAAE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAgBjE;;;;;;;OAOG;IACH,qBAAqB,CAAE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,S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CAAC;QAChB,iBAAiB,EAAE,MAAM,EAAE,CAAC;QAC5B,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB;IAoFH;;SAEK;IACL,KAAK,IAAK,IAAI;IAOd;;;SAGK;IACL,cAAc,CAAE,UAAU,EAAE,MAAM,EAAE;IAYpC;;OAEG;IACH,aAAa,IAAK,MAAM,EAAE;IAK1B;;SAEK;IACL,WAAW,IAAK,MAAM;CA0BvB;AAED,eAAe,IAAI,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Beef } from
|
|
1
|
+
import { Beef } from './Beef.js';
|
|
2
2
|
/**
|
|
3
3
|
* Extends `Beef` that is used to exchange transaction validity data with more than one external party.
|
|
4
4
|
*
|
|
@@ -22,41 +22,52 @@ import { Beef } from "./Beef.js";
|
|
|
22
22
|
*/
|
|
23
23
|
export declare class BeefParty extends Beef {
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
* keys are party identifiers.
|
|
26
|
+
* values are records of txids with truthy value for which the party already has validity proof.
|
|
27
|
+
*/
|
|
28
28
|
knownTo: Record<string, Record<string, boolean>>;
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
*
|
|
31
|
+
* @param parties Optional array of initial unique party identifiers.
|
|
32
|
+
*/
|
|
33
33
|
constructor(parties?: string[]);
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
* @param party
|
|
36
|
+
* @returns `true` if `party` has already beed added to this `BeefParty`.
|
|
37
|
+
*/
|
|
38
38
|
isParty(party: string): boolean;
|
|
39
39
|
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
* Adds a new unique party identifier to this `BeefParty`.
|
|
41
|
+
* @param party
|
|
42
|
+
*/
|
|
43
43
|
addParty(party: string): void;
|
|
44
44
|
/**
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
* @param party
|
|
46
|
+
* @returns Array of txids "known" to `party`.
|
|
47
|
+
*/
|
|
48
48
|
getKnownTxidsForParty(party: string): string[];
|
|
49
49
|
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
* @param party
|
|
51
|
+
* @returns trimmed beef of unknown transactions and proofs for `party`
|
|
52
|
+
*/
|
|
53
53
|
getTrimmedBeefForParty(party: string): Beef;
|
|
54
54
|
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
* Make note of additional txids "known" to `party`.
|
|
56
|
+
* @param party unique identifier, added if new.
|
|
57
|
+
* @param knownTxids
|
|
58
|
+
*/
|
|
59
59
|
addKnownTxidsForParty(party: string, knownTxids: string[]): void;
|
|
60
|
+
/**
|
|
61
|
+
* Merge a `beef` received from a specific `party`.
|
|
62
|
+
*
|
|
63
|
+
* Updates this `BeefParty` to track all the txids
|
|
64
|
+
* corresponding to transactions for which `party`
|
|
65
|
+
* has raw transaction and validity proof data.
|
|
66
|
+
*
|
|
67
|
+
* @param party
|
|
68
|
+
* @param beef
|
|
69
|
+
*/
|
|
70
|
+
mergeBeefFromParty(party: string, beef: number[] | Beef): void;
|
|
60
71
|
}
|
|
61
72
|
export default BeefParty;
|
|
62
73
|
//# sourceMappingURL=BeefParty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeefParty.d.ts","sourceRoot":"","sources":["../../../../src/transaction/BeefParty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"BeefParty.d.ts","sourceRoot":"","sources":["../../../../src/transaction/BeefParty.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,SAAU,SAAQ,IAAI;IACjC;;;SAGK;IACL,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAK;IAErD;;;SAGK;gBACQ,OAAO,CAAC,EAAE,MAAM,EAAE;IAO/B;;;SAGK;IACL,OAAO,CAAE,KAAK,EAAE,MAAM;IAKtB;;;SAGK;IACL,QAAQ,CAAE,KAAK,EAAE,MAAM;IAKvB;;;SAGK;IACL,qBAAqB,CAAE,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAM/C;;;SAGK;IACL,sBAAsB,CAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAO5C;;;;SAIK;IACL,qBAAqB,CAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE;IAS1D;;;;;;;;;OASG;IACH,kBAAkB,CAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI;CAMzD;AAED,eAAe,SAAS,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Reader, Writer } from
|
|
2
|
-
import Transaction from
|
|
1
|
+
import { Reader, Writer } from '../primitives/utils.js';
|
|
2
|
+
import Transaction from './Transaction.js';
|
|
3
3
|
/**
|
|
4
4
|
* A single bitcoin transaction associated with a `Beef` validity proof set.
|
|
5
5
|
*
|
|
@@ -15,7 +15,12 @@ export default class BeefTx {
|
|
|
15
15
|
_rawTx?: number[];
|
|
16
16
|
_txid?: string;
|
|
17
17
|
inputTxids: string[];
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* true if `hasProof` or all inputs chain to `hasProof`.
|
|
20
|
+
*
|
|
21
|
+
* Typically set by sorting transactions by proven dependency chains.
|
|
22
|
+
*/
|
|
23
|
+
isValid?: boolean;
|
|
19
24
|
get bumpIndex(): number | undefined;
|
|
20
25
|
set bumpIndex(v: number | undefined);
|
|
21
26
|
get hasProof(): boolean;
|
|
@@ -24,9 +29,9 @@ export default class BeefTx {
|
|
|
24
29
|
get tx(): Transaction;
|
|
25
30
|
get rawTx(): number[];
|
|
26
31
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
* @param tx If string, must be a valid txid. If `number[]` must be a valid serialized transaction.
|
|
33
|
+
* @param bumpIndex If transaction already has a proof in the beef to which it will be added.
|
|
34
|
+
*/
|
|
30
35
|
constructor(tx: Transaction | number[] | string, bumpIndex?: number);
|
|
31
36
|
private updateInputTxids;
|
|
32
37
|
toWriter(writer: Writer, magic: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BeefTx.d.ts","sourceRoot":"","sources":["../../../../src/transaction/BeefTx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAkB,MAAM,wBAAwB,CAAA;AACvE,OAAO,WAAW,MAAM,kBAAkB,CAAA;AAG1C;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;
|
|
1
|
+
{"version":3,"file":"BeefTx.d.ts","sourceRoot":"","sources":["../../../../src/transaction/BeefTx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAkB,MAAM,wBAAwB,CAAA;AACvE,OAAO,WAAW,MAAM,kBAAkB,CAAA;AAG1C;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,GAAG,CAAC,EAAE,WAAW,CAAA;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,EAAE,CAAK;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAY;IAE7B,IAAI,SAAS,IAAK,MAAM,GAAG,SAAS,CAA2B;IAE/D,IAAI,SAAS,CAAE,CAAC,EAAE,MAAM,GAAG,SAAS,EAGnC;IAED,IAAI,QAAQ,IAAK,OAAO,CAEvB;IAED,IAAI,UAAU,IAAK,OAAO,CAEzB;IAED,IAAI,IAAI,WAKP;IAED,IAAI,EAAE,gBAIL;IAED,IAAI,KAAK,aAIR;IAED;;;SAGK;gBACQ,EAAE,EAAE,WAAW,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAcpE,OAAO,CAAC,gBAAgB;IAUxB,QAAQ,CAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAgC9C,MAAM,CAAC,UAAU,CAAE,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM;CA8BtD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MerklePath.d.ts","sourceRoot":"","sources":["../../../../src/transaction/MerklePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,wBAAwB,CAAA;AAEvE,OAAO,YAAY,MAAM,mBAAmB,CAAA;AAE5C,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;QAChB,MAAM,EAAE,MAAM,CAAA;QACd,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,OAAO,CAAA;QACd,SAAS,CAAC,EAAE,OAAO,CAAA;KACpB,CAAC,CAAC,CAAA;IAEH;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,
|
|
1
|
+
{"version":3,"file":"MerklePath.d.ts","sourceRoot":"","sources":["../../../../src/transaction/MerklePath.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAA0B,MAAM,wBAAwB,CAAA;AAEvE,OAAO,YA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AAM,CAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC;IAMzE;;;;;OAKG;IACH,OAAO,CAAE,KAAK,EAAE,UAAU,GAAG,IAAI;IA+BjC;;;;OAIG;IACH,IAAI;CA+CL"}
|
|
@@ -263,17 +263,23 @@ export default class Transaction {
|
|
|
263
263
|
/**
|
|
264
264
|
* Serializes this transaction, together with its inputs and the respective merkle proofs, into the BEEF (BRC-62) format. This enables efficient verification of its compliance with the rules of SPV.
|
|
265
265
|
*
|
|
266
|
+
* @param allowPartial If true, error will not be thrown if there are any missing sourceTransactions.
|
|
267
|
+
*
|
|
266
268
|
* @returns The serialized BEEF structure
|
|
269
|
+
* @throws Error if there are any missing sourceTransactions unless `allowPartial` is true.
|
|
267
270
|
*/
|
|
268
|
-
toBEEF(): number[];
|
|
271
|
+
toBEEF(allowPartial?: boolean): number[];
|
|
269
272
|
/**
|
|
270
273
|
* Serializes this transaction and its inputs into the Atomic BEEF (BRC-95) format.
|
|
271
274
|
* The Atomic BEEF format starts with a 4-byte prefix `0x01010101`, followed by the TXID of the subject transaction,
|
|
272
275
|
* and then the BEEF data containing only the subject transaction and its dependencies.
|
|
273
276
|
* This format ensures that the BEEF structure is atomic and contains no unrelated transactions.
|
|
274
277
|
*
|
|
278
|
+
* @param allowPartial If true, error will not be thrown if there are any missing sourceTransactions.
|
|
279
|
+
*
|
|
275
280
|
* @returns {number[]} - The serialized Atomic BEEF structure.
|
|
281
|
+
* @throws Error if there are any missing sourceTransactions unless `allowPartial` is true.
|
|
276
282
|
*/
|
|
277
|
-
toAtomicBEEF(): number[];
|
|
283
|
+
toAtomicBEEF(allowPartial?: boolean): number[];
|
|
278
284
|
}
|
|
279
285
|
//# sourceMappingURL=Transaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transaction.d.ts","sourceRoot":"","sources":["../../../../src/transaction/Transaction.ts"],"names":[],"mappings":"AAAA,O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