fundrawtransaction add inputs bug #14656

issue n0n0n0n0 opened this issue on November 5, 2018
  1. n0n0n0n0 commented at 8:31 AM on November 5, 2018: none

    According to description of rpc method: "Add inputs to a transaction until it has enough in value to meet its out value."

    What i have:

    • trying to send 5000 satoshis
    • have thousand of unspent inputs in wallet

    Steps:

    • i'm calling createrawtransaction with empty inputs and my address-amount output
    • use fundrawtransaction to fill needed amount
    • to check that use decoderawtransaction

    so, the transaction bitcoind build is https://tchain.btc.com/bfedf6fb29b699bf57573af4ebee370f48f7153015bb7110fa61fbb90ed0b072

    uhm i see tons of inputs with amount > i wanted to send, fee is only 2073 so any of input with 10k satoshi was enough

    so the final question, how it should work? according to description "until it has enough in value" it should take only one input from example above, but not so many.

  2. meshcollider added the label RPC/REST/ZMQ on Nov 5, 2018
  3. promag commented at 3:31 PM on November 5, 2018: member

    Could you specify the software version used?

  4. MarcoFalke added the label Wallet on Nov 5, 2018
  5. n0n0n0n0 commented at 4:00 AM on November 6, 2018: none

    2018-11-06T04:00:55Z Bitcoin Core version v0.17.0.0-ge1ed37edaedc85b8c3468bd9a726046344036243 (release build)

  6. sipa commented at 4:02 AM on November 6, 2018: member

    That's perfectly normal. The coin selection algorithm uses a heuristic which doesn't necessarily result in the smallest number of inputs.

  7. n0n0n0n0 commented at 4:07 AM on November 6, 2018: none

    If so i think need to correct description, i expected behaviour as it was written, but got a lot of inputs. Anyway i still cant understand what the point of adding so many inputs and make transaction bigger if we have input with enough coins.

  8. sipa commented at 4:10 AM on November 6, 2018: member

    @n0n0n0n0 Coin selection is a very difficult problem. It's not just trying to minimize cost right now, but also tries to avoid ending up with too many tiny outputs later (which would be costly to spend in the future). Further there are privacy considerations, long-term UTXO growth considerations on the network, and last but not least implementation complexity. It doesn't always find the best solution, but very often it's a good one.

  9. sipa closed this on Nov 6, 2018

  10. MarcoFalke commented at 3:53 PM on November 6, 2018: member

    If you want to optimize the input selection for a specific transaction, you might want to manually select the inputs.

  11. promag commented at 4:03 PM on November 6, 2018: member

    @sipa agree in updating fundrawtransaction description? Maybe change Add inputs to a transaction until it has enough in value to meet its out value to Add inputs to a transaction to at least meet its output value?

  12. sipa commented at 5:28 PM on November 6, 2018: member

    @promag It's probably better to just say "performs coin selection on the wallet and adds inputs and change accordingly". Explaining what coin selection does is probably not possible in a single paragraph without giving wrong expectations. @n0n0n0n0 I believe what happened here is that it's deciding to spend all outputs created by a single transaction simultaneously, because they're already linked.

  13. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me