Module: OpenReceive

Defined in:
lib/openreceive/core.rb,
lib/openreceive/rates.rb,
lib/openreceive/version.rb,
lib/openreceive/nwc_ruby.rb,
lib/openreceive/keccak256.rb,
lib/openreceive/swap_address.rb

Defined Under Namespace

Modules: Keccak256, Money, Nwc, Payments, Rates, Settlement, SwapAddress Classes: NwcRubyReceiveClient, NwcUriParseError, PriceFeedError, WalletUnavailableError

Constant Summary collapse

NWC_CODE_HELP_URL =
"https://openreceive.org/get_a_nwc_code_to_receive_payments"
NWC_METADATA_MAX_BYTES =
3900
MIN_AMOUNT_MSATS =
1000
MAX_AMOUNT_MSATS =
9_007_199_254_740_991
TRANSACTION_PAGE_LIMIT =

Mirrors JS OPENRECEIVE_TRANSACTION_PAGE_LIMIT: the page size every wallet-history walk requests.

20
HEX_64_PATTERN =
/\A[0-9a-fA-F]{64}\z/
VERSION =
"0.3.0"

Class Method Summary collapse

Class Method Details

.as_string_keys(hash) ⇒ Object



565
566
567
# File 'lib/openreceive/core.rb', line 565

def as_string_keys(hash)
  hash.each_pair.to_h { |key, item| [key.to_s, item] }
end

.list_incoming_transactions(client:, expected:, from: nil, until_time: nil, max_pages: nil, include_unpaid: false) ⇒ Object



601
602
603
604
605
606
607
608
609
610
# File 'lib/openreceive/core.rb', line 601

def list_incoming_transactions(client:, expected:, from: nil, until_time: nil, max_pages: nil, include_unpaid: false)
  Payments.list_incoming_transactions(
    client: client,
    expected: expected,
    from: from,
    until_time: until_time,
    max_pages: max_pages,
    include_unpaid: include_unpaid
  )
end

.list_transactions_nip47_request(request) ⇒ Object



593
594
595
# File 'lib/openreceive/core.rb', line 593

def list_transactions_nip47_request(request)
  Nwc.list_transactions_request(request)
end

.make_invoice_nip47_request(request) ⇒ Object



585
586
587
# File 'lib/openreceive/core.rb', line 585

def make_invoice_nip47_request(request)
  Nwc.make_invoice_request(request)
end

.normalize_list_transactions_response(response) ⇒ Object



597
598
599
# File 'lib/openreceive/core.rb', line 597

def normalize_list_transactions_response(response)
  Nwc.normalize_list_transactions_response(response)
end

.normalize_make_invoice_response(response) ⇒ Object



589
590
591
# File 'lib/openreceive/core.rb', line 589

def normalize_make_invoice_response(response)
  Nwc.normalize_make_invoice_response(response)
end

.parse_nwc_uri(uri) ⇒ Object



577
578
579
# File 'lib/openreceive/core.rb', line 577

def parse_nwc_uri(uri)
  Nwc.parse_uri(uri)
end

.quote_fiat_to_msats(fiat_value:, btc_fiat_price:) ⇒ Object



569
570
571
# File 'lib/openreceive/core.rb', line 569

def quote_fiat_to_msats(fiat_value:, btc_fiat_price:)
  Money.quote_fiat_to_msats(fiat_value: fiat_value, btc_fiat_price: btc_fiat_price)
end

.redact_nwc_uri(uri) ⇒ Object



581
582
583
# File 'lib/openreceive/core.rb', line 581

def redact_nwc_uri(uri)
  Nwc.redact_uri(uri)
end

.settled?(transaction) ⇒ Boolean

Returns:

  • (Boolean)


573
574
575
# File 'lib/openreceive/core.rb', line 573

def settled?(transaction)
  Settlement.settled?(transaction)
end

.stringify(value) ⇒ Object

Wire payloads reach both engines with string keys, symbol keys, or as a wallet SDK value object. Both helpers flatten that to string keys; they differ only in what they do with a non-hash. stringify tolerates it and returns {} — use it on anything a third party supplied. as_string_keys does not — use it where the caller has already proven the value is a hash, so a missing hash fails loudly at the source instead of as a KeyError later.



560
561
562
563
# File 'lib/openreceive/core.rb', line 560

def stringify(value)
  return {} unless value.respond_to?(:each_pair)
  as_string_keys(value)
end