@bsv/sdk 1.3.18 → 1.3.20

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.
@@ -2004,13 +2004,16 @@ Represents a chain tracker based on What's On Chain .
2004
2004
  export default class WhatsOnChain implements ChainTracker {
2005
2005
  readonly network: string;
2006
2006
  readonly apiKey: string;
2007
+ protected readonly URL: string;
2008
+ protected readonly httpClient: HttpClient;
2007
2009
  constructor(network: "main" | "test" | "stn" = "main", config: WhatsOnChainConfig = {})
2008
2010
  async isValidRootForHeight(root: string, height: number): Promise<boolean>
2009
2011
  async currentHeight(): Promise<number>
2012
+ protected getHttpHeaders(): Record<string, string>
2010
2013
  }
2011
2014
  ```
2012
2015
 
2013
- See also: [ChainTracker](./transaction.md#interface-chaintracker), [WhatsOnChainConfig](./transaction.md#interface-whatsonchainconfig)
2016
+ See also: [ChainTracker](./transaction.md#interface-chaintracker), [HttpClient](./transaction.md#interface-httpclient), [WhatsOnChainConfig](./transaction.md#interface-whatsonchainconfig)
2014
2017
 
2015
2018
  #### Constructor
2016
2019
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsv/sdk",
3
- "version": "1.3.18",
3
+ "version": "1.3.20",
4
4
  "type": "module",
5
5
  "description": "BSV Blockchain Software Development Kit",
6
6
  "main": "dist/cjs/mod.js",
@@ -504,7 +504,7 @@ export class Beef {
504
504
 
505
505
  const writer = new Writer()
506
506
  writer.writeUInt32LE(ATOMIC_BEEF)
507
- writer.write(toArray(txid, 'hex'))
507
+ writer.writeReverse(toArray(txid, 'hex'))
508
508
  beef.toWriter(writer)
509
509
 
510
510
  return writer.toArray()
@@ -523,7 +523,7 @@ export class Beef {
523
523
  let atomicTxid: string | undefined
524
524
  if (version === ATOMIC_BEEF) {
525
525
  // Skip the txid and re-read the BEEF version
526
- atomicTxid = toHex(br.read(32))
526
+ atomicTxid = toHex(br.readReverse(32))
527
527
  version = br.readUInt32LE()
528
528
  }
529
529
  if (version !== BEEF_V1 && version !== BEEF_V2) {
@@ -986,7 +986,7 @@ export default class Transaction {
986
986
  // Write the Atomic BEEF prefix
987
987
  writer.writeUInt32LE(0x01010101)
988
988
  // Write the subject TXID (big-endian)
989
- writer.write(this.id())
989
+ writer.write(this.hash())
990
990
  // Append the BEEF data
991
991
  const beefData = this.toBEEF(allowPartial)
992
992
  writer.write(beefData)
@@ -1034,7 +1034,7 @@ describe('Transaction', () => {
1034
1034
  // Verify that the Atomic BEEF starts with the correct prefix and TXID
1035
1035
  const expectedPrefix = [0x01, 0x01, 0x01, 0x01]
1036
1036
  expect(atomicBEEF.slice(0, 4)).toEqual(expectedPrefix)
1037
- const txid = spendTx.id()
1037
+ const txid = spendTx.hash()
1038
1038
  expect(atomicBEEF.slice(4, 36)).toEqual(txid)
1039
1039
 
1040
1040
  // Deserialize from Atomic BEEF
@@ -1049,7 +1049,7 @@ describe('Transaction', () => {
1049
1049
  writer.writeUInt32LE(0x01010101)
1050
1050
  // Write subject TXID
1051
1051
  const fakeTXID = toArray('00'.repeat(32), 'hex')
1052
- writer.write(fakeTXID)
1052
+ writer.writeReverse(fakeTXID)
1053
1053
  // Write empty BEEF data
1054
1054
  writer.writeUInt32LE(BEEF_V1) // BEEF version
1055
1055
  writer.writeVarIntNum(0) // No BUMPs
@@ -1198,7 +1198,7 @@ describe('Transaction', () => {
1198
1198
  // Verify that the Atomic BEEF starts with the correct prefix and TXID
1199
1199
  const expectedPrefix = [0x01, 0x01, 0x01, 0x01]
1200
1200
  expect(atomicBEEF.slice(0, 4)).toEqual(expectedPrefix)
1201
- const txid = spendTx.id()
1201
+ const txid = spendTx.hash()
1202
1202
  expect(atomicBEEF.slice(4, 36)).toEqual(txid)
1203
1203
 
1204
1204
  // Deserialize from Atomic BEEF
@@ -1213,7 +1213,7 @@ describe('Transaction', () => {
1213
1213
  writer.writeUInt32LE(0x01010101)
1214
1214
  // Write subject TXID
1215
1215
  const fakeTXID = toArray('00'.repeat(32), 'hex')
1216
- writer.write(fakeTXID)
1216
+ writer.writeReverse(fakeTXID)
1217
1217
  // Write empty BEEF data
1218
1218
  writer.writeUInt32LE(BEEF_V1) // BEEF version
1219
1219
  writer.writeVarIntNum(0) // No BUMPs
@@ -21,8 +21,8 @@ interface WhatsOnChainBlockHeader {
21
21
  export default class WhatsOnChain implements ChainTracker {
22
22
  readonly network: string
23
23
  readonly apiKey: string
24
- private readonly URL: string
25
- private readonly httpClient: HttpClient
24
+ protected readonly URL: string
25
+ protected readonly httpClient: HttpClient
26
26
 
27
27
  /**
28
28
  * Constructs an instance of the WhatsOnChain ChainTracker.
@@ -88,7 +88,7 @@ export default class WhatsOnChain implements ChainTracker {
88
88
  }
89
89
  }
90
90
 
91
- private getHttpHeaders(): Record<string, string> {
91
+ protected getHttpHeaders(): Record<string, string> {
92
92
  const headers: Record<string, string> = {
93
93
  Accept: 'application/json'
94
94
  }