Never create uneconomical output #7677

issue NicolasDorier opened this issue on March 14, 2016
  1. NicolasDorier commented at 10:07 AM on March 14, 2016: contributor

    I noticed that wallet.cpp and coincontroldialog.cpp try to not produce dust output.

    The original intention of "dust" is to not create uneconomical output. However, using minTxRelayFee as the basis for minimum output value we don't ensure uneconomical output, we only ensure that the transaction is not rejected by our own node policy.

    A change of default minTxRelayFee as done in #6793 can suddenly mean that a transaction created by a wallet will not be accepted by other nodes because you are still using the old minTxRelayFee when creating your transactions.

    Using estimatedFee instead of minTxRelayFee in wallet code would not only make sure that the creation of an output is economically profitable, but also ensure that a sudden change of minTxRelayFee by other nodes don't impact the confirmation time of transaction created by the wallet. It has the indirect advantage to make the UTXO smaller.

    I will probably try to implement that, I just want your thoughts about the idea first.

  2. laanwj added the label Wallet on Mar 14, 2016
  3. chris-belcher commented at 1:15 PM on March 14, 2016: contributor

    This requires predicting future prices.

    Previously economical outputs might become uneconomical because of a rise in miner fees. Previously uneconomical outputs might become economical because of a rise in bitcoin's exchange rate or new technology (CoinJoin, OP_SCHNORR)

    Probably the best that can be done is to make them economical today.

  4. laanwj added the label Brainstorming on Mar 14, 2016
  5. NicolasDorier commented at 2:02 PM on March 14, 2016: contributor

    Probably the best that can be done is to make them economical today.

    Indeed estimatefee take the decision based on today's price which is the best we can do. This is still closer to reality than using minTxRelayFee.

    or new technology (CoinJoin, OP_SCHNORR)

    This is orthogonal. Currently the Dust depends on the ScriptPubKey size. (should be ScriptSig size in theory but it is not, which is normal as not all scriptSig size can be estimated before being built)

  6. Xekyo commented at 6:09 PM on November 8, 2016: member

    @NicolasDorier: AFAIK dust calculates from the size of a P2PKH input (148 bytes) plus the size of a P2PKH output (34 bytes). The 148 bytes seem to be hardcoded:

        size_t nSize = GetSerializeSize(SER_DISK, 0);
        int witnessversion = 0;
        std::vector<unsigned char> witnessprogram;
    
        if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
            // sum the sizes of the parts of a transaction input
            // with 75% segwit discount applied to the script size.
            nSize += (32 + 4 + 1 + (107 / WITNESS_SCALE_FACTOR) + 4);
        } else {
            nSize += (32 + 4 + 1 + 107 + 4); // the 148 mentioned above
        }
    

    Not sure whether that's what you said. ;)

  7. Leviathn commented at 1:31 PM on September 5, 2017: none

    @nicholasdorier is this still pending? Not sure whether resolvable, may be closeable.

  8. Leviathn commented at 1:32 PM on September 5, 2017: none
  9. MarcoFalke commented at 10:47 PM on September 5, 2017: member

    Related pulls: #10817, #10637

  10. NicolasDorier commented at 9:52 AM on September 10, 2017: contributor
  11. morcos commented at 10:50 PM on September 10, 2017: member

    I believe this can be closed.

    For a long time Core has tried not to produce change below .01 BTC.

    In the edge cases where we can't create change that high, the rate at which we'll throw away a change output has been increased by 10/3 to the discard rate.

    But at the end of the day its still possible to have an output just above the dust rate if you ask to pay someone that.

  12. NicolasDorier commented at 4:08 AM on September 11, 2017: contributor

    Ok, closing that, will reopen if I encounter the problem again.

  13. NicolasDorier closed this on Sep 11, 2017

  14. 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 21:15 UTC

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