Developer Guide
Sending (BTC Line of Credit)
16 min
sending payments with bitcoin line of credit this guide explains how to send lightning network and on chain bitcoin payments from a btc denominated wallet using the voltage payments api prerequisites a voltage account with an active btc wallet (wallet associated with a bitcoin line of credit) an api key (from the "api keys" page in your dashboard) no quotes needed! unlike usd wallets, btc wallets send payments directly in btc without currency conversion you do not need to use the quotes api sending a payment endpoint post https //voltageapi com/v1/organizations/{organization id}/environments/{environment id}/payments headers x api key your api key content type application/json lightning payment (bolt11) { "id" "68d00852 8dd8 4c71 94d2 91c84695da78", "wallet id" "7a68a525 9d11 4c1e a3dd 1c2bf1378ba2", "currency" "btc", "type" "bolt11", "data" { "payment request" "lntbs1500n1p ", "amount" { "currency" "btc", "amount" 150000, "unit" "msats" }, "max fee" { "currency" "btc", "amount" 1000, "unit" "msats" } } } request fields id – unique identifier for the payment (uuid you create) wallet id – id of the btc wallet sending the payment currency – must be "btc" type – "bolt11" for lightning payments data payment request – the lightning invoice to pay (required, cannot be empty) data amount – optional when payment request already contains an amount; required when payment request has no amount; if provided with an amount containing invoice, values must match (in msats) data max fee – optional maximum routing fee (defaults to 1% of payment value or 1,000 msats, whichever is greater) on chain payment { "id" "2ec1e783 19b4 4c10 8181 66336a6232bd", "wallet id" "7a68a525 9d11 4c1e a3dd 1c2bf1378ba2", "currency" "btc", "type" "onchain", "data" { "address" "tb1pzkhtj4ld86g9c49du5yagnncfrm0s489t76vmrwmt2ecxfnf7spsvjte49", "amount" { "currency" "btc", "amount" 15000000, "unit" "msats" }, "max fee" { "currency" "btc", "amount" 1000000, "unit" "msats" }, "description" "test payment" } } request fields type – "onchain" for on chain payments data address – the recipient's bitcoin address data amount – amount to send in msats (15,000,000 msats = 15,000 sats) data max fee – optional maximum miner fee in msats data description – optional memo for accounting simplicity, please separate lightning and on chain usage between different wallets if you are on a node backed setup unified payment (bip21) a bip21 uri can include both an on chain address and a lightning invoice { "id" "3e84b6c5 5bbe 4e0f 9fb3 f1198330f6fa", "wallet id" "7a68a525 9d11 4c1e a3dd 1c2bf1378ba2", "currency" "btc", "type" "bip21", "data" { "address" "bitcoin\ tb1pzkhtj4ld86g9c49du5yagnncfrm0s489t76vmrwmt2ecxfnf7spsvjte49?lightning=lntbs1500n1p ", "payment request" "lntbs1500n1p ", "amount" { "currency" "btc", "amount" 150000, "unit" "msats" }, "max fee" { "currency" "btc", "amount" 1000, "unit" "msats" }, "description" "payment for services" } } required fields id – unique identifier for the payment (uuid you create) wallet id – id of the btc wallet sending the payment currency – must be "btc" type – must be "bip21" data address – bip21 uri to pay (cannot be empty) optional fields data payment request – lightning invoice (if you want to pass it separately) data amount – btc amount object in msats data max fee – btc amount object in msats (max lightning fee) data description – optional description/memo example implementations lightning payment curl 'https //voltageapi com/v1/organizations/{organization id}/environments/{environment id}/payments' \\ \ request post \\ \ header 'x api key your api key' \\ \ header 'content type application/json' \\ \ data '{ "id" "68d00852 8dd8 4c71 94d2 91c84695da78", "wallet id" "7a68a525 9d11 4c1e a3dd 1c2bf1378ba2", "currency" "btc", "type" "bolt11", "data" { "payment request" "lntbs1500n1p ", "amount" { "currency" "btc", "amount" 150000 }, "max fee" { "currency" "btc", "amount" 1000 } } }' on chain payment curl 'https //voltageapi com/v1/organizations/{organization id}/environments/{environment id}/payments' \\ \ request post \\ \ header 'x api key your api key' \\ \ header 'content type application/json' \\ \ data '{ "id" "2ec1e783 19b4 4c10 8181 66336a6232bd", "wallet id" "7a68a525 9d11 4c1e a3dd 1c2bf1378ba2", "currency" "btc", "type" "onchain", "data" { "address" "tb1pzkhtj4ld86g9c49du5yagnncfrm0s489t76vmrwmt2ecxfnf7spsvjte49", "amount" { "currency" "btc", "amount" 15000000 }, "max fee" { "currency" "btc", "amount" 1000000 }, "description" "test payment" } }' monitoring payment status after sending a payment, monitor its status using get https //voltageapi com/v1/organizations/{organization id}/environments/{environment id}/payments/{payment id} example curl 'https //voltageapi com/v1/organizations/{organization id}/environments/{environment id}/payments/{payment id}' \\ \ header 'x api key your api key' payment states sending – payment is in progress completed – payment was successful failed – payment failed (check the error field for details) error handling http status codes 200 – success 400 – invalid request (check error message) 403 – authentication error 404 – payment not found 500 – server error common errors invalid invoice – the lightning invoice is malformed or expired insufficient balance – your btc wallet doesn't have enough funds route not found – no viable lightning route to the destination invalid address – the bitcoin address is invalid