Invoice
How to create, send, and manage invoices in the Fiber network
This page is a work in progress. More detailed examples and advanced usage patterns will be added soon. For the protocol-level specification, see Invoice Protocol.
An invoice is a payment request generated by a recipient. It encodes all the information a sender needs to make a payment — the amount, the recipient's identity, and a cryptographic proof of payment.
What is an Invoice?
Think of an invoice as a "payment QR code." The recipient generates one, and the sender scans it (or copies the encoded string) to initiate a payment. The invoice contains:
- Amount (optional — can be left open for donations)
- Payment hash — a cryptographic commitment to a secret (preimage) that proves payment
- Recipient's public key — identifies who should receive the payment
- Expiry time — how long the invoice is valid
- Description — a human-readable note (e.g., "Coffee")
Invoice Format
Fiber invoices use bech32m encoding (similar to Lightning's BOLT 11, but not compatible):
- Mainnet prefix:
fibb(fiber bytes, since 1 CKB = 1 Byte) - Testnet prefix:
fibt - Dev prefix:
fibd
Example: fibt100amount...encoded_data...signature
For the full encoding specification, see Invoice Protocol.
Creating an Invoice
Using fnn-cli
fnn-cli invoice new_invoice --amount 1000 --currency fibt --description "Test payment"Using RPC
{
"jsonrpc": "2.0",
"method": "new_invoice",
"params": [
{
"amount": "0x3E8",
"currency": "fibt",
"description": "Test payment",
"expiry": 3600
}
],
"id": 1
}Paying an Invoice
Using fnn-cli
fnn-cli payment send_payment --invoice "fibt1..."Using RPC
{
"jsonrpc": "2.0",
"method": "send_payment",
"params": [
{
"invoice": "fibt1..."
}
],
"id": 1
}Invoice States
| State | Description |
|---|---|
| Open | The invoice has been created but not yet paid |
| Settled | Payment has been received and the preimage has been revealed |
| Cancelled | The invoice has been manually cancelled or has expired |
| Accepted | (Hold invoice only) Payment is in transit but not yet settled |
Managing Invoices
| Action | RPC Method | fnn-cli |
|---|---|---|
| Create invoice | new_invoice | fnn-cli invoice new_invoice |
| Parse invoice | parse_invoice | fnn-cli invoice parse_invoice |
| Get invoice status | get_invoice | fnn-cli invoice get_invoice |
| Cancel invoice | cancel_invoice | fnn-cli invoice cancel_invoice |
| Settle invoice (hold) | settle_invoice | fnn-cli invoice settle_invoice |
Related Topics
- Hold Invoice — deferred settlement for conditional payments
- Invoice Protocol — the technical specification
- Payment Lifecycle — how payments are processed after an invoice is paid