mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
Implements the NWC-321 (BIP-321 Lightning Payments) pay and receive methods, limited to BOLT-11 instructions: - pay parses the BIP-321 URI, selects the lightning (BOLT-11) instruction and rejects URIs without one (UNSUPPORTED_PAYMENT_INSTRUCTION), validates the invoice network against the node network (UNSUPPORTED_NETWORK), rejects conflicting or invalid amounts, unknown req- parameters and payer_note (undeliverable over BOLT-11) - receive returns a BIP-321 URI containing a single BOLT-11 invoice; a variable amount is rejected as zero-amount invoices are not supported - both methods reuse the existing pay_invoice / make_invoice scopes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
90 lines
2.7 KiB
Go
90 lines
2.7 KiB
Go
package constants
|
|
|
|
// shared constants used by multiple packages
|
|
|
|
const (
|
|
TRANSACTION_TYPE_INCOMING = "incoming"
|
|
TRANSACTION_TYPE_OUTGOING = "outgoing"
|
|
|
|
TRANSACTION_STATE_PENDING = "PENDING"
|
|
TRANSACTION_STATE_SETTLED = "SETTLED"
|
|
TRANSACTION_STATE_FAILED = "FAILED"
|
|
TRANSACTION_STATE_ACCEPTED = "ACCEPTED"
|
|
|
|
SWAP_TYPE_IN = "in"
|
|
SWAP_TYPE_OUT = "out"
|
|
|
|
SWAP_STATE_PENDING = "PENDING"
|
|
SWAP_STATE_SUCCESS = "SUCCESS"
|
|
SWAP_STATE_FAILED = "FAILED"
|
|
SWAP_STATE_REFUNDED = "REFUNDED"
|
|
)
|
|
|
|
const (
|
|
BUDGET_RENEWAL_DAILY = "daily"
|
|
BUDGET_RENEWAL_WEEKLY = "weekly"
|
|
BUDGET_RENEWAL_MONTHLY = "monthly"
|
|
BUDGET_RENEWAL_YEARLY = "yearly"
|
|
BUDGET_RENEWAL_NEVER = "never"
|
|
)
|
|
|
|
func GetBudgetRenewals() []string {
|
|
return []string{
|
|
BUDGET_RENEWAL_DAILY,
|
|
BUDGET_RENEWAL_WEEKLY,
|
|
BUDGET_RENEWAL_MONTHLY,
|
|
BUDGET_RENEWAL_YEARLY,
|
|
BUDGET_RENEWAL_NEVER,
|
|
}
|
|
}
|
|
|
|
const (
|
|
PAY_INVOICE_SCOPE = "pay_invoice" // also covers pay_keysend and multi_* payment methods
|
|
GET_BALANCE_SCOPE = "get_balance"
|
|
GET_INFO_SCOPE = "get_info"
|
|
MAKE_INVOICE_SCOPE = "make_invoice"
|
|
LOOKUP_INVOICE_SCOPE = "lookup_invoice"
|
|
LIST_TRANSACTIONS_SCOPE = "list_transactions"
|
|
SIGN_MESSAGE_SCOPE = "sign_message"
|
|
NOTIFICATIONS_SCOPE = "notifications" // covers all notification types
|
|
SUPERUSER_SCOPE = "superuser"
|
|
)
|
|
|
|
// limit encoded metadata length, otherwise relays may have trouble listing multiple transactions
|
|
// given a relay limit of 512000 bytes and ideally being able to list 25 transactions,
|
|
// each transaction would have to have a maximum size of 20480
|
|
// accounting for encryption and other metadata in the response, this is set to 4096 characters
|
|
const INVOICE_METADATA_MAX_LENGTH = 4096
|
|
|
|
// errors used by NIP-47 and the transaction service
|
|
const (
|
|
ERROR_INTERNAL = "INTERNAL"
|
|
ERROR_NOT_IMPLEMENTED = "NOT_IMPLEMENTED"
|
|
ERROR_QUOTA_EXCEEDED = "QUOTA_EXCEEDED"
|
|
ERROR_INSUFFICIENT_BALANCE = "INSUFFICIENT_BALANCE"
|
|
ERROR_UNAUTHORIZED = "UNAUTHORIZED"
|
|
ERROR_EXPIRED = "EXPIRED"
|
|
ERROR_RESTRICTED = "RESTRICTED"
|
|
ERROR_BAD_REQUEST = "BAD_REQUEST"
|
|
ERROR_NOT_FOUND = "NOT_FOUND"
|
|
ERROR_UNSUPPORTED_ENCRYPTION = "UNSUPPORTED_ENCRYPTION"
|
|
ERROR_OTHER = "OTHER"
|
|
|
|
// NWC-321 (BIP-321 payments) errors
|
|
ERROR_UNSUPPORTED_PAYMENT_INSTRUCTION = "UNSUPPORTED_PAYMENT_INSTRUCTION"
|
|
ERROR_UNSUPPORTED_NETWORK = "UNSUPPORTED_NETWORK"
|
|
)
|
|
|
|
const (
|
|
ENCRYPTION_TYPE_NIP04 = "nip04"
|
|
ENCRYPTION_TYPE_NIP44_V2 = "nip44_v2"
|
|
)
|
|
|
|
const METADATA_APPSTORE_APP_ID_KEY = "app_store_app_id"
|
|
|
|
const SUBWALLET_APPSTORE_APP_ID = "uncle-jim"
|
|
|
|
const (
|
|
BITCOIN_DISPLAY_FORMAT_SATS = "sats"
|
|
BITCOIN_DISPLAY_FORMAT_BIP177 = "bip177"
|
|
)
|