brk-client 0.3.0-beta.5 → 0.3.0-beta.6

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 (2) hide show
  1. package/index.js +69 -2
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -845,6 +845,31 @@ Matches mempool.space/bitcoin-cli behavior.
845
845
  *
846
846
  * @typedef {number} RawLockTime
847
847
  */
848
+ /**
849
+ * Response body for `GET /api/v1/tx/:txid/rbf`. Both fields are null
850
+ * when the tx has no known RBF history within the mempool monitor's
851
+ * graveyard retention window.
852
+ *
853
+ * @typedef {Object} RbfResponse
854
+ * @property {(ReplacementNode|null)=} replacements
855
+ * @property {?Txid[]=} replaces
856
+ */
857
+ /**
858
+ * Transaction summary carried inside an RBF replacement node. Shape
859
+ * matches mempool.space's `/api/v1/tx/:txid/rbf` and
860
+ * `/api/v1/replacements` responses.
861
+ *
862
+ * @typedef {Object} RbfTx
863
+ * @property {Txid} txid
864
+ * @property {Sats} fee
865
+ * @property {VSize} vsize
866
+ * @property {Sats} value - Sum of output amounts.
867
+ * @property {FeeRate} rate
868
+ * @property {Timestamp} time
869
+ * @property {boolean} rbf - BIP-125 signaling: at least one input has sequence < 0xffffffff-1.
870
+ * @property {?boolean=} fullRbf - Only populated on the root `tx` of an RBF response. `true` iff
871
+ this tx displaced at least one non-signaling predecessor.
872
+ */
848
873
  /**
849
874
  * Recommended fee rates in sat/vB
850
875
  *
@@ -855,6 +880,19 @@ Matches mempool.space/bitcoin-cli behavior.
855
880
  * @property {FeeRate} economyFee - Fee rate for economical confirmation
856
881
  * @property {FeeRate} minimumFee - Minimum relay fee rate
857
882
  */
883
+ /**
884
+ * One node in an RBF replacement tree. The node's `tx` replaced each
885
+ * entry in `replaces`, recursively.
886
+ *
887
+ * @typedef {Object} ReplacementNode
888
+ * @property {RbfTx} tx
889
+ * @property {Timestamp} time - First-seen timestamp, duplicated here to match mempool.space's
890
+ on-the-wire shape.
891
+ * @property {boolean} fullRbf - Any predecessor in this subtree was non-signaling.
892
+ * @property {?number=} interval - Seconds between this node's `time` and the successor that
893
+ replaced it. Omitted on the root of an RBF response.
894
+ * @property {ReplacementNode[]} replaces
895
+ */
858
896
  /**
859
897
  * Block reward statistics over a range of blocks
860
898
  *
@@ -1060,7 +1098,7 @@ Matches mempool.space/bitcoin-cli behavior.
1060
1098
  * @property {(TxOut|null)=} prevout - Information about the previous output being spent
1061
1099
  * @property {string} scriptsig - Signature script (hex, for non-SegWit inputs)
1062
1100
  * @property {string} scriptsigAsm - Signature script in assembly format
1063
- * @property {string[]} witness - Witness data (hex-encoded stack items, present for SegWit inputs)
1101
+ * @property {Witness} witness - Witness data (stack items, present for SegWit inputs; hex-encoded on the wire)
1064
1102
  * @property {boolean} isCoinbase - Whether this input is a coinbase (block reward) input
1065
1103
  * @property {number} sequence - Input sequence number
1066
1104
  * @property {string} innerRedeemscriptAsm - Inner redeemscript in assembly (for P2SH-wrapped SegWit: scriptsig + witness both present)
@@ -1240,6 +1278,17 @@ Matches mempool.space/bitcoin-cli behavior.
1240
1278
  *
1241
1279
  * @typedef {number} Weight
1242
1280
  */
1281
+ /**
1282
+ * Transaction witness: a stack of byte arrays, one per witness item.
1283
+ *
1284
+ * Wraps `bitcoin::Witness` (single-buffer layout with offsets, much
1285
+ * more compact than `Vec<Vec<u8>>`). Serializes as a JSON array of
1286
+ * hex strings - the format used by Bitcoin Core REST and mempool.space
1287
+ * and matching brk's `script_sig: ScriptBuf` (bytes internally, hex
1288
+ * on the wire).
1289
+ *
1290
+ * @typedef {string[]} Witness
1291
+ */
1243
1292
  /** @typedef {number} Year1 */
1244
1293
  /** @typedef {number} Year10 */
1245
1294
 
@@ -7222,7 +7271,7 @@ function createTransferPattern(client, acc) {
7222
7271
  * @extends BrkClientBase
7223
7272
  */
7224
7273
  class BrkClient extends BrkClientBase {
7225
- VERSION = "v0.3.0-beta.5";
7274
+ VERSION = "v0.3.0-beta.6";
7226
7275
 
7227
7276
  INDEXES = /** @type {const} */ ([
7228
7277
  "minute10",
@@ -11599,6 +11648,24 @@ class BrkClient extends BrkClientBase {
11599
11648
  return this.getJson(path, { signal, onUpdate });
11600
11649
  }
11601
11650
 
11651
+ /**
11652
+ * RBF replacement history
11653
+ *
11654
+ * Returns the RBF replacement tree for a transaction, if any. Both `replacements` and `replaces` are null when the tx has no known RBF history within the mempool monitor's retention window.
11655
+ *
11656
+ * *[Mempool.space docs](https://mempool.space/docs/api/rest#get-transaction-rbf-history)*
11657
+ *
11658
+ * Endpoint: `GET /api/v1/tx/{txid}/rbf`
11659
+ *
11660
+ * @param {Txid} txid
11661
+ * @param {{ signal?: AbortSignal, onUpdate?: (value: RbfResponse) => void }} [options]
11662
+ * @returns {Promise<RbfResponse>}
11663
+ */
11664
+ async getTxRbf(txid, { signal, onUpdate } = {}) {
11665
+ const path = `/api/v1/tx/${txid}/rbf`;
11666
+ return this.getJson(path, { signal, onUpdate });
11667
+ }
11668
+
11602
11669
  /**
11603
11670
  * Validate address
11604
11671
  *
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "url": "git+https://github.com/bitcoinresearchkit/brk.git"
41
41
  },
42
42
  "type": "module",
43
- "version": "0.3.0-beta.5"
43
+ "version": "0.3.0-beta.6"
44
44
  }