@bsv/sdk 1.2.14 → 1.2.17

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.
Files changed (38) hide show
  1. package/dist/cjs/package.json +2 -2
  2. package/dist/cjs/src/script/templates/P2PKH.js +2 -0
  3. package/dist/cjs/src/script/templates/P2PKH.js.map +1 -1
  4. package/dist/cjs/src/transaction/Beef.js +41 -15
  5. package/dist/cjs/src/transaction/Beef.js.map +1 -1
  6. package/dist/cjs/src/transaction/MerklePath.js +4 -4
  7. package/dist/cjs/src/transaction/MerklePath.js.map +1 -1
  8. package/dist/cjs/src/transaction/Transaction.js +26 -0
  9. package/dist/cjs/src/transaction/Transaction.js.map +1 -1
  10. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  11. package/dist/esm/src/script/templates/P2PKH.js +2 -0
  12. package/dist/esm/src/script/templates/P2PKH.js.map +1 -1
  13. package/dist/esm/src/transaction/Beef.js +41 -15
  14. package/dist/esm/src/transaction/Beef.js.map +1 -1
  15. package/dist/esm/src/transaction/MerklePath.js +4 -4
  16. package/dist/esm/src/transaction/MerklePath.js.map +1 -1
  17. package/dist/esm/src/transaction/Transaction.js +26 -0
  18. package/dist/esm/src/transaction/Transaction.js.map +1 -1
  19. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  20. package/dist/types/src/script/templates/P2PKH.d.ts.map +1 -1
  21. package/dist/types/src/transaction/Beef.d.ts +8 -2
  22. package/dist/types/src/transaction/Beef.d.ts.map +1 -1
  23. package/dist/types/src/transaction/MerklePath.d.ts +2 -2
  24. package/dist/types/src/transaction/MerklePath.d.ts.map +1 -1
  25. package/dist/types/src/transaction/Transaction.d.ts +8 -0
  26. package/dist/types/src/transaction/Transaction.d.ts.map +1 -1
  27. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  28. package/dist/umd/bundle.js +1 -1
  29. package/docs/transaction.md +31 -4
  30. package/docs/wallet-substrates.md +1410 -1
  31. package/package.json +2 -2
  32. package/src/script/templates/P2PKH.ts +1 -0
  33. package/src/transaction/Beef.ts +49 -8
  34. package/src/transaction/MerklePath.ts +4 -4
  35. package/src/transaction/Transaction.ts +22 -0
  36. package/src/transaction/__tests/Beef.test.ts +24 -5
  37. package/src/transaction/__tests/Transaction.benchmarks.test.ts +2 -2
  38. package/src/transaction/__tests/Transaction.test.ts +44 -0
@@ -624,6 +624,7 @@ export class Beef {
624
624
  trimKnownTxids(knownTxids: string[])
625
625
  getValidTxids(): string[]
626
626
  toLogString(): string
627
+ addComputedLeaves()
627
628
  }
628
629
  ```
629
630
 
@@ -633,6 +634,15 @@ See also: [BeefTx](#class-beeftx), [BeefVersion](#type-beefversion), [ChainTrack
633
634
 
634
635
  <summary>Class Beef Details</summary>
635
636
 
637
+ #### Method addComputedLeaves
638
+
639
+ In some circumstances it may be helpful for the BUMP MerkePaths to include
640
+ leaves that can be computed from row zero.
641
+
642
+ ```ts
643
+ addComputedLeaves()
644
+ ```
645
+
636
646
  #### Method clone
637
647
 
638
648
  ```ts
@@ -902,8 +912,9 @@ A binary array representing the BEEF
902
912
 
903
913
  Serialize this Beef as AtomicBEEF.
904
914
 
905
- `txid` must exist and be the last transaction
906
- in sorted (dependency) order.
915
+ `txid` must exist
916
+
917
+ after sorting, if txid is not last txid, creates a clone and removes newer txs
907
918
 
908
919
  ```ts
909
920
  toBinaryAtomic(txid: string)
@@ -1217,7 +1228,7 @@ export default class MerklePath {
1217
1228
  duplicate?: boolean;
1218
1229
  }>>;
1219
1230
  static fromHex(hex: string): MerklePath
1220
- static fromReader(reader: Reader): MerklePath
1231
+ static fromReader(reader: Reader, legalOffsetsOnly: boolean = true): MerklePath
1221
1232
  static fromBinary(bump: number[]): MerklePath
1222
1233
  static fromCoinbaseTxidAndHeight(txid: string, height: number): MerklePath
1223
1234
  constructor(blockHeight: number, path: Array<Array<{
@@ -1225,7 +1236,7 @@ export default class MerklePath {
1225
1236
  hash?: string;
1226
1237
  txid?: boolean;
1227
1238
  duplicate?: boolean;
1228
- }>>)
1239
+ }>>, legalOffsetsOnly: boolean = true)
1229
1240
  toBinary(): number[]
1230
1241
  toHex(): string
1231
1242
  computeRoot(txid?: string): string
@@ -1524,6 +1535,7 @@ export default class Transaction {
1524
1535
  constructor(version: number = 1, inputs: TransactionInput[] = [], outputs: TransactionOutput[] = [], lockTime: number = 0, metadata: Record<string, any> = {}, merklePath?: MerklePath)
1525
1536
  addInput(input: TransactionInput): void
1526
1537
  addOutput(output: TransactionOutput): void
1538
+ addP2PKHOutput(address: number[] | string, satoshis?: number): void
1527
1539
  updateMetadata(metadata: Record<string, any>): void
1528
1540
  async fee(modelOrFee: FeeModel | number = new SatoshisPerKilobyte(10), changeDistribution: "equal" | "random" = "equal"): Promise<void>
1529
1541
  getFee(): number
@@ -1583,6 +1595,21 @@ Argument Details
1583
1595
  + **output**
1584
1596
  + The TransactionOutput object to add to the transaction.
1585
1597
 
1598
+ #### Method addP2PKHOutput
1599
+
1600
+ Adds a new P2PKH output to the transaction.
1601
+
1602
+ ```ts
1603
+ addP2PKHOutput(address: number[] | string, satoshis?: number): void
1604
+ ```
1605
+
1606
+ Argument Details
1607
+
1608
+ + **address**
1609
+ + The P2PKH address of the output.
1610
+ + **satoshis**
1611
+ + The number of satoshis to send to the address - if not provided, the output is considered a change output.
1612
+
1586
1613
  #### Method broadcast
1587
1614
 
1588
1615
  Broadcasts a transaction.