Module: X402

Defined in:
lib/x402/bsv/proof_gateway.rb,
lib/x402.rb,
lib/x402/errors.rb,
lib/x402/wallet.rb,
lib/x402/railtie.rb,
lib/x402/version.rb,
lib/x402/middleware.rb,
lib/x402/bsv/gateway.rb,
lib/x402/configuration.rb,
lib/x402/remote_wallet.rb,
lib/x402/bsv/txid_store.rb,
lib/x402/protocol/proof.rb,
lib/x402/bsv/pay_gateway.rb,
lib/x402/status_endpoint.rb,
lib/x402/bsv/prefix_store.rb,
lib/x402/payment_observer.rb,
lib/x402/settlement_result.rb,
lib/x402/settlement_worker.rb,
lib/x402/bsv/brc105_gateway.rb,
lib/x402/bsv/brc121_gateway.rb,
lib/x402/protocol/base64url.rb,
lib/x402/protocol/challenge.rb,
lib/x402/tasks/wallet_setup.rb,
lib/x402/bsv/challenge_store.rb,
lib/x402/protocol/request_binding.rb,
lib/x402/verification/protocol_checks.rb

Overview

NO PAY -> NO CONTENT: this gateway serves content if and only if the vendor has verified that the payment transaction was accepted by ARC. The invariant is enforced by +#settle_payment!+ (below), which is called between output verification and +internalize_action+ so wallet state is never mutated for a transaction ARC refused.

Settlement is BEEF-type-aware:

  • Full BEEF (+subject_txid+ nil): the client has NOT broadcast — the vendor broadcasts via +arc.broadcast+.
  • Atomic BEEF (+subject_txid+ set): the client signals it already broadcast — the vendor verifies via +arc.status+.

ARC's idempotency guarantees duplicate broadcasts of an already-seen tx are safe. See README "What x402-rack guarantees".

Defined Under Namespace

Modules: BSV, Base64Url, RequestBinding, Tasks, Verification, Wallet Classes: Challenge, Configuration, ConfigurationError, Error, Middleware, PaymentObserver, Proof, Railtie, RemoteWallet, SettlementResult, SettlementWorker, StatusEndpoint, VerificationError

Constant Summary collapse

VERSION =
"0.11.1"

Class Method Summary collapse

Class Method Details

.configurationObject



20
21
22
# File 'lib/x402.rb', line 20

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Yields:



15
16
17
18
# File 'lib/x402.rb', line 15

def configure
  yield(configuration)
  configuration.validate!
end

.reset_configuration!Object



24
25
26
# File 'lib/x402.rb', line 24

def reset_configuration!
  @configuration = Configuration.new
end