Saturday, June 28, 2025
Homeบิทคอยน์bitcoin core - How do I calculate transaction price for name to...

bitcoin core – How do I calculate transaction price for name to createpsbt()?


When my consumer invokes my app, he passes as an enter parameter the specified worth of the TX price in satoshis per byte. I create a PSBT by calling createpsbt(). I exert full management over the willpower of inputs and outputs. For instance, I do not name walletcreatefundedpsbt(), as a result of I do not need bitcoind to pick out inputs on my behalf. I’ve a hen and egg drawback in that I must name createpsbt() in an effort to decide the scale of the TX in bytes, however I must specify the price quantity earlier than the decision to createpsbt(). One of the best answer that I can consider is to execute a dummy name to createpsbt() utilizing a dummy price worth, then measure the scale of the TX, then do an actual name to createpsbt() after accurately calculating the price quantity. Is there a greater approach?

Edit: I need to spend all UTXOs. I need two outputs, one to obtain a hard and fast quantity, the opposite to obtain change much less the price. I’ve tried many incantations, I am unable to get it to work. Here is my newest try:

raw_psbt = rpc.walletcreatefundedpsbt(
    # all UTXOs, as returned by listunspent():
    inputs,
    # one recipient: [ { addr : amount } ]
    outputs,
    0,  # locktime
    {
        "replaceable" : True,
        # I would really like for the change much less the price to go right here:
        "changeAddress" : xxx,
        "includeWatching" : True,
        "feeRate" : 0.005,
    }
)

This fails with Signing transaction failed (-4). Any concept what I am doing mistaken?

Edit #2: I am unable to use walletcreatefundedpsbt() as steered under to create the PSBT, as a result of that operate requires that its inputs be “solvable”, which isn’t the case in my setting. Extra data at this hyperlink:

Errors with walletcreatefundedpsbt & non-solvable UTXOs

So my authentic query stays unresolved at this level.

Edit #3: So I requested on Slack. The issue is that our UTXOs are 1) not “solvable” and a pair of) can’t be expressed within the descriptor language, so Bitcoin Core has no strategy to calculate the TX measurement earlier than the TX is signed. Apparently I must calculated it manually as defined within the hooked up screenshot.slack chat

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

ความเห็นล่าสุด