Class X402::BSV::Gateway ¶
Inherits: Object
Base gateway class for BSV settlement schemes.
Builds partial transaction templates containing a payment output. The OP_RETURN request binding is NOT included in the template βit must be appended last by the client to preserve SIGHASH_SINGLE index alignment (input N β output N for each signer).
When a wallet is provided, each challenge derives a unique payee address via BRC-29 key derivation, preventing address reuse.
Constants¶
BRC29_PROTOCOL_ID ¶
BRC-29 protocol ID β shared with BRC-105 and BRC-121 so all gateways derive keys the wallet can spend via the same scheme.
Attributes¶
payee_locking_script_hex [R] ¶
Returns the value of attribute payee_locking_script_hex.
Public Instance Methods¶
build_template(_rack_request, required_sats) ¶
Build a partial transaction template for the given route.
Output 0: payment (amount_sats to payee locking script)
The OP_RETURN is NOT included β the client appends it last so that SIGHASH_SINGLE index alignment is preserved (each signer's input index matches their change output index). - @param rack_request [Rack::Request] - @param route [X402::Configuration::Route] - @return [Array(BSV::Transaction::Transaction, String, String, String)] transaction, payee script hex, derivation prefix, derivation suffix
initialize(payee_locking_script_hex: = nil, wallet: = nil, challenge_secret: = nil) ¶
- @param
payee_locking_script_hex[String, nil] static payee script hex; falls back to X402.configuration.payee_locking_script_hex if nil. Ignored when wallet is provided (derived addresses used instead). - @param
wallet[BSV::Wallet::ProtoWallet, nil] wallet for key derivation. When provided, each challenge gets a unique derived payee address. - @param
challenge_secret[String, nil] HMAC secret for signing challenge data. Auto-generated if not provided. Used to verify payTo hasn't been tampered with. - @return [Gateway] a new instance of Gateway
request_binding_hash(rack_request) ¶
Compute the SHA-256 hash used for request binding. - @param rack_request [Rack::Request] - @return [String] 32-byte binary hash