Class: X402::PaymentObserver::StaticRecogniser

Inherits:
Object
  • Object
show all
Defined in:
lib/x402/payment_observer.rb

Overview

Built-in recogniser for a single static payee address. Used when +payee_locking_script_hex+ is provided without a custom recogniser.

Instance Method Summary collapse

Constructor Details

#initialize(payee_locking_script_hex) ⇒ StaticRecogniser

Returns a new instance of StaticRecogniser.

Parameters:

  • payee_locking_script_hex (String)

    hex-encoded locking script to match



158
159
160
# File 'lib/x402/payment_observer.rb', line 158

def initialize(payee_locking_script_hex)
  @payee_hex = ::BSV::Script::Script.from_hex(payee_locking_script_hex).to_hex
end

Instance Method Details

#ours?(locking_script_hex) ⇒ Boolean

Returns true if the script matches the configured payee.

Parameters:

  • locking_script_hex (String)

    hex-encoded locking script to test

Returns:

  • (Boolean)

    true if the script matches the configured payee



164
165
166
# File 'lib/x402/payment_observer.rb', line 164

def ours?(locking_script_hex)
  locking_script_hex == @payee_hex
end