@bsv/sdk 1.1.30 → 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/transaction/Beef.js +161 -45
- package/dist/cjs/src/transaction/Beef.js.map +1 -1
- package/dist/cjs/src/transaction/BeefParty.js +16 -0
- package/dist/cjs/src/transaction/BeefParty.js.map +1 -1
- package/dist/cjs/src/transaction/BeefTx.js +6 -1
- package/dist/cjs/src/transaction/BeefTx.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/transaction/Beef.js +160 -44
- package/dist/esm/src/transaction/Beef.js.map +1 -1
- package/dist/esm/src/transaction/BeefParty.js +16 -0
- package/dist/esm/src/transaction/BeefParty.js.map +1 -1
- package/dist/esm/src/transaction/BeefTx.js +6 -1
- package/dist/esm/src/transaction/BeefTx.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/transaction/Beef.d.ts +44 -3
- package/dist/types/src/transaction/Beef.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefParty.d.ts +11 -0
- package/dist/types/src/transaction/BeefParty.d.ts.map +1 -1
- package/dist/types/src/transaction/BeefTx.d.ts +6 -1
- package/dist/types/src/transaction/BeefTx.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/transaction.md +141 -9
- package/package.json +1 -1
- package/src/transaction/Beef.ts +186 -47
- package/src/transaction/BeefParty.ts +17 -0
- package/src/transaction/BeefTx.ts +6 -1
- package/src/transaction/Transaction.ts +12 -6
- package/src/transaction/__tests/Beef.test.ts +55 -10
|
@@ -1,9 +1,17 @@
|
|
|
1
|
+
// The following imports allow flag a large number type checking errors by the VsCode editor due to missing type information:
|
|
1
2
|
import BeefTx from "../../../dist/cjs/src/transaction/BeefTx"
|
|
2
3
|
import Beef from "../../../dist/cjs/src/transaction/Beef"
|
|
3
4
|
import BeefParty from "../../../dist/cjs/src/transaction/BeefParty"
|
|
4
5
|
import { BEEF_MAGIC, BEEF_MAGIC_V2 } from "../../../dist/cjs/src/transaction/Beef"
|
|
5
6
|
import Transaction from "../../../dist/cjs/src/transaction/Transaction"
|
|
6
7
|
|
|
8
|
+
// The following imports allow full type checking by the VsCode editor, but tests will fail to run:
|
|
9
|
+
//import BeefTx from '../BeefTx'
|
|
10
|
+
//import Beef from '../Beef'
|
|
11
|
+
//import BeefParty from "../BeefParty"
|
|
12
|
+
//import { BEEF_MAGIC, BEEF_MAGIC_V2 } from "../Beef"
|
|
13
|
+
//import Transaction from "../Transaction"
|
|
14
|
+
|
|
7
15
|
describe('Beef tests', () => {
|
|
8
16
|
jest.setTimeout(99999999)
|
|
9
17
|
|
|
@@ -56,8 +64,8 @@ describe('Beef tests', () => {
|
|
|
56
64
|
expect(btx.rawTx).toBe(undefined)
|
|
57
65
|
}
|
|
58
66
|
|
|
59
|
-
const
|
|
60
|
-
expect(
|
|
67
|
+
const r = beef.sortTxs()
|
|
68
|
+
expect(r.missingInputs.length).toBe(0)
|
|
61
69
|
expect(beef.toLogString()).toBe(log2)
|
|
62
70
|
|
|
63
71
|
{
|
|
@@ -72,8 +80,8 @@ describe('Beef tests', () => {
|
|
|
72
80
|
{
|
|
73
81
|
const beef = new Beef()
|
|
74
82
|
beef.mergeTransaction(Transaction.fromHex(txs[0]))
|
|
75
|
-
const
|
|
76
|
-
expect(
|
|
83
|
+
const { missingInputs } = beef.sortTxs()
|
|
84
|
+
expect(missingInputs).toEqual(['bd4a39c6dce3bdd982be3c67eb04b83934fd431f8bcb64f9da4413c91c634d07'])
|
|
77
85
|
const beef0 = Beef.fromString(beefs[0])
|
|
78
86
|
beef.mergeBump(beef0.bumps[0])
|
|
79
87
|
beef.mergeRawTx(beef0.txs[0].rawTx!, undefined)
|
|
@@ -215,10 +223,10 @@ describe('Beef tests', () => {
|
|
|
215
223
|
const v = bp.getTrimmedBeefForParty('a').toLogString()
|
|
216
224
|
expect(v).toBe(`BEEF with 0 BUMPS and 2 Transactions, isValid false
|
|
217
225
|
TX 0
|
|
218
|
-
txid:
|
|
226
|
+
txid: 3
|
|
219
227
|
txidOnly
|
|
220
228
|
TX 1
|
|
221
|
-
txid:
|
|
229
|
+
txid: 4
|
|
222
230
|
txidOnly
|
|
223
231
|
`)
|
|
224
232
|
}
|
|
@@ -226,10 +234,10 @@ describe('Beef tests', () => {
|
|
|
226
234
|
const v = bp.getTrimmedBeefForParty('b').toLogString()
|
|
227
235
|
expect(v).toBe(`BEEF with 0 BUMPS and 2 Transactions, isValid false
|
|
228
236
|
TX 0
|
|
229
|
-
txid:
|
|
237
|
+
txid: 1
|
|
230
238
|
txidOnly
|
|
231
239
|
TX 1
|
|
232
|
-
txid:
|
|
240
|
+
txid: 2
|
|
233
241
|
txidOnly
|
|
234
242
|
`)
|
|
235
243
|
}
|
|
@@ -237,15 +245,52 @@ describe('Beef tests', () => {
|
|
|
237
245
|
const v = bp.getTrimmedBeefForParty('c').toLogString()
|
|
238
246
|
expect(v).toBe(`BEEF with 0 BUMPS and 2 Transactions, isValid false
|
|
239
247
|
TX 0
|
|
240
|
-
txid:
|
|
248
|
+
txid: 1
|
|
241
249
|
txidOnly
|
|
242
250
|
TX 1
|
|
243
|
-
txid:
|
|
251
|
+
txid: 4
|
|
244
252
|
txidOnly
|
|
245
253
|
`)
|
|
246
254
|
}
|
|
247
255
|
})
|
|
248
256
|
|
|
257
|
+
test('5_AtomicBeef', async () => {
|
|
258
|
+
{
|
|
259
|
+
const beef = Beef.fromString(beefs[0])
|
|
260
|
+
expect(beef.toHex()).toBe(beefs[0])
|
|
261
|
+
const sr = beef.sortTxs()
|
|
262
|
+
const beefHex = beef.toHex()
|
|
263
|
+
const tx = beef.txs[beef.txs.length - 1].tx!
|
|
264
|
+
expect(tx).toBeTruthy()
|
|
265
|
+
const atomic = tx.toAtomicBEEF(true)
|
|
266
|
+
// Verify that atomic BEEF can be deserialized.
|
|
267
|
+
const beef2 = Beef.fromBinary(atomic)
|
|
268
|
+
// The merkle path isn't linked to tx by default.
|
|
269
|
+
expect(beef2.toHex()).not.toBe(beefHex)
|
|
270
|
+
{
|
|
271
|
+
const atx = beef.findAtomicTransaction(tx.id('hex'))
|
|
272
|
+
const atomic = atx.toAtomicBEEF(true)
|
|
273
|
+
// Verify that atomic BEEF can be deserialized.
|
|
274
|
+
const beef2 = Beef.fromBinary(atomic)
|
|
275
|
+
// The merkle path now is linked to tx by default.
|
|
276
|
+
expect(beef2.toHex()).toBe(beefHex)
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
{
|
|
280
|
+
const beef = Beef.fromString(beefs[0])
|
|
281
|
+
expect(beef.toHex()).toBe(beefs[0])
|
|
282
|
+
beef.mergeTransaction(Transaction.fromHex(txs[0]))
|
|
283
|
+
const sr = beef.sortTxs()
|
|
284
|
+
const beefHex = beef.toHex()
|
|
285
|
+
const tx = beef.txs[beef.txs.length - 1].tx!
|
|
286
|
+
expect(tx).toBeTruthy()
|
|
287
|
+
const atx = beef.findAtomicTransaction(tx.id('hex'))
|
|
288
|
+
const atomic = atx.toAtomicBEEF()
|
|
289
|
+
// Verify that atomic BEEF can be deserialized.
|
|
290
|
+
const beef2 = Beef.fromBinary(atomic)
|
|
291
|
+
expect(beef2.toHex()).toBe(beefHex)
|
|
292
|
+
}
|
|
293
|
+
})
|
|
249
294
|
})
|
|
250
295
|
|
|
251
296
|
const txs: string[] = [
|