Description
I am using LND with external coinselection, it just so happened that one utxo was almost the same value as the output + fee - so my coinselection algorithm produced a 1-in 1-out transaction. However when trying to pass these parameters to fundPsbt, it returns an error UnexpectedErrorFundingTransaction: wallet couldn't fund PSBT: could not add change address to database: fee estimation not successful: insufficient funds available to construct transaction
, here are the params used:
{
inputs: [
{
transaction_id: '086e6d5f538fadb464c7c4c631f86b5522cac1eeee5f535dfafe96c47e1208ad',
transaction_vout: 0
}
],
outputs: [
{
address: 'tb1qd0s3u22y6sp7h57uul5feua8668yeujktr4vlg',
tokens: 9883
}
],
fee_tokens_per_vbyte: undefined,
min_confirmations: undefined
}
The input utxo has 10001 sats (you can check it on testnet: https://mempool.space/testnet/tx/086e6d5f538fadb464c7c4c631f86b5522cac1eeee5f535dfafe96c47e1208ad), this results in 10001-9883 = 118 sats fee, which should be enough for 1-in 1-out p2wpkh transaction. It seems like LND tries to add change output to it even though it is not required, and that change output causes the input value to be insufficient to cover the fees for such a transaction.
Is there a way to tell LND not to add any change output in the fundPsbt call? Or is there a way to generate the psbt on the client side without calling fundPsbt and then just sign it by LND using signPsbt - in that case I guess I would somehow need to get key derivation paths for the inputs, right?