Class: BSV::Transaction::Beef::BeefTx
- Inherits:
-
Object
- Object
- BSV::Transaction::Beef::BeefTx
- Defined in:
- lib/bsv/transaction/beef.rb
Overview
A single entry in a BEEF bundle, wrapping a transaction with its format metadata.
Instance Attribute Summary collapse
-
#bump_index ⇒ Integer?
readonly
Index into the BEEF bumps array.
-
#format ⇒ Integer
readonly
Format flag (FORMAT_RAW_TX, FORMAT_RAW_TX_AND_BUMP, or FORMAT_TXID_ONLY).
-
#known_wtxid ⇒ String?
readonly
32-byte wire-order wtxid for TXID-only entries.
-
#transaction ⇒ Transaction?
readonly
The transaction (nil for TXID-only entries).
Instance Method Summary collapse
-
#dtxid ⇒ String?
Display-order transaction ID as a hex string.
-
#initialize(format:, transaction: nil, known_wtxid: nil, bump_index: nil) ⇒ BeefTx
constructor
A new instance of BeefTx.
-
#txid ⇒ String?
Display-order transaction ID as binary bytes.
-
#wtxid ⇒ String?
Wire-order transaction ID.
Constructor Details
#initialize(format:, transaction: nil, known_wtxid: nil, bump_index: nil) ⇒ BeefTx
Returns a new instance of BeefTx.
58 59 60 61 62 63 64 65 66 |
# File 'lib/bsv/transaction/beef.rb', line 58 def initialize(format:, transaction: nil, known_wtxid: nil, bump_index: nil) raise ArgumentError, 'FORMAT_RAW_TX_AND_BUMP requires a bump_index' if format == FORMAT_RAW_TX_AND_BUMP && bump_index.nil? BSV::Primitives::Hex.validate_wtxid!(known_wtxid, name: 'known_wtxid') if known_wtxid @format = format @transaction = transaction @known_wtxid = known_wtxid @bump_index = bump_index end |
Instance Attribute Details
#bump_index ⇒ Integer? (readonly)
Returns index into the BEEF bumps array.
51 52 53 |
# File 'lib/bsv/transaction/beef.rb', line 51 def bump_index @bump_index end |
#format ⇒ Integer (readonly)
Returns format flag (FORMAT_RAW_TX, FORMAT_RAW_TX_AND_BUMP, or FORMAT_TXID_ONLY).
42 43 44 |
# File 'lib/bsv/transaction/beef.rb', line 42 def format @format end |
#known_wtxid ⇒ String? (readonly)
Returns 32-byte wire-order wtxid for TXID-only entries.
48 49 50 |
# File 'lib/bsv/transaction/beef.rb', line 48 def known_wtxid @known_wtxid end |
#transaction ⇒ Transaction? (readonly)
Returns the transaction (nil for TXID-only entries).
45 46 47 |
# File 'lib/bsv/transaction/beef.rb', line 45 def transaction @transaction end |
Instance Method Details
#dtxid ⇒ String?
Display-order transaction ID as a hex string.
dtxid always returns a 64-char hex string suitable for JSON and UI boundaries.
91 92 93 |
# File 'lib/bsv/transaction/beef.rb', line 91 def dtxid wtxid&.reverse&.unpack1('H*') end |
#txid ⇒ String?
Display-order transaction ID as binary bytes.
81 82 83 |
# File 'lib/bsv/transaction/beef.rb', line 81 def txid wtxid&.reverse end |
#wtxid ⇒ String?
Wire-order transaction ID.
70 71 72 73 74 75 76 77 |
# File 'lib/bsv/transaction/beef.rb', line 70 def wtxid case @format when FORMAT_TXID_ONLY @known_wtxid else @transaction&.wtxid end end |