When my user calls my app, he is passed as an input parameter. Call it to create a PSBT createpsbt()
. Full control over input and output decisions. For example, I don’t call walletcreatefundedpsbt()
Because I don’t want to choose input on my behalf to bitcoind. I have a chicken and egg problem in that I need to call createpsbt()
To determine the size of TX in bytes, you must specify the fee amount before the call createpsbt()
. The best solution I can think of is to perform a dummy call createpsbt()
Use the dummy fee value to measure the size of the TX and make the actual call createpsbt()
After calculating the fee amount correctly. Is there a better way?
edit: I want to use all utxos. You need two outputs. One receives a fixed amount and the other receives a change in the fee. I have tried many spells, I can’t make it work. Here is my latest attempt:
raw_psbt = rpc.walletcreatefundedpsbt(
# all UTXOs, as returned by listunspent():
inputs,
# one recipient: ( { addr : amount } )
outputs,
0, # locktime
{
"replaceable" : True,
# I would like for the change less the fee to go here:
"changeAddress" : xxx,
"includeWatching" : True,
"feeRate" : 0.005,
}
)
This fails Signing transaction failed (-4)
. Are you thinking about what I’m doing?
Edit #2: Cannot be used walletcreatefundedpsbt()
As suggested below, in my environment, in order to create a PSBT, its input must be “solvable” in that function. Details of this link:
Error in walletcreatefundedpsbt
& Unweldable utxos
So my original question remains unresolved at this point.
Edit #3: So I asked in Slack. The problem is that Bitcoin core does not have a way to calculate the TX size before TX is signed, since UTXOS cannot be expressed in 1) in a descriptor language, rather than 2) in a descriptor language. Apparently, you will need to do the calculations manually, as explained in the attached screenshot.
Discover more from Earlybirds Invest
Subscribe to get the latest posts sent to your email.