Problem
I set up a Bitpay test account and loaded my Bitpay wallet with testnet BTC. However I’m seeing an in an "Insufficient funds for fee"
error when paying an invoice with the Bitpay Java SDK. Double checked the BTC amount in my wallet and it’s less than the entire total (including the fee) and even tried manually setting the miner fee to 0 from the Invoice object.
Expected Behavior
Client should not receive “Insufficient funds for fee” error when opening the URL generated by the Invoice.
Code
// Config file
{
"BitPayConfiguration" : {
"Environment" : "Test",
"EnvConfig" : {
"Test" : {
"PrivateKeyPath" : "",
"PrivateKey" : "xxx",
"ApiTokens" : {
"payout" : "yyy",
"merchant" : "zzz"
}
}
}
}
}
// app code
fun createClient() {
val configFilePath = ConfigFilePath("src/main/resources/BitPay.config.json")
bitpayClient = Client.createClientByConfigFilePath(configFilePath)
}
fun createInvoice(bitpayClient: Client) {
var invoice = Invoice(0.00002, Currency.BTC)
invoice.autoRedirect = true
invoice = bitpayClient.createInvoice(invoice)
invoice.merchantName = null
invoice.minerFees.btc.satoshisPerByte = 0.0
invoice.minerFees.btc.totalFee = 0
val result: Invoice = bitpayClient.createInvoice(invoice)
}
Balances and total due
- testnet BTC balance: 0.00033
- total due (BTC): 0.00017439