invoices: multi-crypto payment support
One asset per invoice from a registry (lib/crypto_asset.rb): BTC, LTC, ETH, XMR, SOL, ALGO, USDT/USDC on ERC-20/TRC-20/BEP-20/Solana/Algorand. Migration 003 generalizes the ltc_* columns to crypto_* + crypto_coin (existing LTC invoices backfilled). QR payload adapts per asset: BIP21 amount URIs where supported, bare address for tokens with a network hint on the PDF. Default addresses come from the CRYPTO_ADDRESSES secret (JSON code=>address); LTC_ADDRESS still works as legacy.
This commit is contained in:
parent
f9c7001e7a
commit
0fbb6ee809
20 changed files with 410 additions and 143 deletions
22
db/migrations/003_invoice_crypto.rb
Normal file
22
db/migrations/003_invoice_crypto.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
Sequel.migration do
|
||||
up do
|
||||
alter_table(:invoices) do
|
||||
# Generalize the Litecoin-only columns: one crypto asset per invoice,
|
||||
# identified by crypto_coin (a CryptoAsset code, e.g. 'BTC', 'USDT-TRC20').
|
||||
rename_column :ltc_address, :crypto_address
|
||||
rename_column :ltc_rate, :crypto_rate
|
||||
rename_column :ltc_amount, :crypto_amount
|
||||
add_column :crypto_coin, String
|
||||
end
|
||||
run "UPDATE invoices SET crypto_coin = 'LTC' WHERE crypto_address IS NOT NULL"
|
||||
end
|
||||
|
||||
down do
|
||||
alter_table(:invoices) do
|
||||
drop_column :crypto_coin
|
||||
rename_column :crypto_address, :ltc_address
|
||||
rename_column :crypto_rate, :ltc_rate
|
||||
rename_column :crypto_amount, :ltc_amount
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue