Class: X402::PaymentObserver::CoinbaseV2Extractor
- Inherits:
-
Object
- Object
- X402::PaymentObserver::CoinbaseV2Extractor
- Defined in:
- lib/x402/payment_observer.rb
Overview
Built-in extractor for the Coinbase v2 envelope format. Decodes +Base64(JSON({ payload: { rawtx: "hex" } }))+.
Instance Method Summary collapse
-
#call(proof_payload) ⇒ BSV::Transaction::Transaction?
Parsed transaction or nil on failure.
Instance Method Details
#call(proof_payload) ⇒ BSV::Transaction::Transaction?
Returns parsed transaction or nil on failure.
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/x402/payment_observer.rb', line 139 def call(proof_payload) json = Base64.strict_decode64(proof_payload) payload = JSON.parse(json) rawtx_hex = payload.dig("payload", "rawtx") return unless rawtx_hex tx_binary = [rawtx_hex].pack("H*") ::BSV::Transaction::Transaction.from_binary(tx_binary) rescue StandardError nil end |