How to change send BTCs algorithm? #7736

issue JokerCatz opened this issue on March 23, 2016
  1. JokerCatz commented at 5:04 AM on March 23, 2016: none

    Hi dev team , my production nodes is ver 0.11.2 and split 2 group : receiver nodes & sender nodes , receiver is customer wallets , sender is send to outside wallet , and I need move receiver BTCs to sender node

    I use sendtoaddress command :

    #SKIP
    $ bitcoin-cli sendtoaddress WALLET 0.4
    TXID
    $ bitcoin-cli sendtoaddress WALLET 0.4
    error: {"code":-4,"message":"Transaction too large"}
    $ bitcoin-cli sendtoaddress WALLET 0.3
    error: {"code":-4,"message":"Transaction too large"}
    $ bitcoin-cli sendtoaddress WALLET 0.25
    error: {"code":-4,"message":"Transaction too large"}
    $ bitcoin-cli sendtoaddress WALLET 0.20
    TXID
    $ bitcoin-cli sendtoaddress WALLET 0.2
    error: {"code":-4,"message":"Transaction too large"}
    $ bitcoin-cli sendtoaddress WALLET 0.15
    TXID
    $ bitcoin-cli sendtoaddress WALLET 0.2
    error: {"code":-4,"message":"Transaction too large"}
    $ bitcoin-cli listaccounts
    {
        "" : OVER20
    }
    $ bitcoin-cli sendtoaddress WALLET 0.2
    error: {"code":-4,"message":"Transaction too large"}
    $ bitcoin-cli sendtoaddress WALLET 0.15
    TXID
    $ bitcoin-cli sendtoaddress WALLET 0.15
    error: {"code":-4,"message":"Transaction too large"}
    $ bitcoin-cli sendtoaddress WALLET 0.1
    TXID
    $ bitcoin-cli sendtoaddress WALLET 0.1 ##dust is clean here
    TXID
    $ bitcoin-cli sendtoaddress WALLET 1
    TXID
    $ bitcoin-cli sendtoaddress WALLET 10
    TXID
    $ bitcoin-cli listaccounts
    {
        "" : OVER20
    }
    $ bitcoin-cli sendtoaddress WALLET OVER20
    TXID
    $ bitcoin-cli listaccounts
    {
        "" : CLEANED
    }
    

    I remove some details(same command and large number test) , but you can see dust be clean and some bigger amount send after dust

    so how to change send BTCs algorithm? like "bigger" or "smaller" BTCs send first with out "age"? has option or need edit the source code and compile bitcoin core? or has another command or program can help me to clean dust? like

    https://github.com/petertodd/dust-b-gone

    but I need send to sender , not same node clean up , or just fast way to send all BTCs to sender wallet , any idea?

  2. jonasschnelli added the label Wallet on Mar 23, 2016
  3. laanwj commented at 10:34 AM on March 23, 2016: member

    I suppose you mean the coin selection algorithm? You can change it in in CWallet::SelectCoins https://github.com/bitcoin/bitcoin/blob/master/src/wallet/wallet.cpp#L1844

    However if you need custom coin selection you might as well use listunspent RPC from an external script to get the available coins, and build and send transactions using the raw transactions API. This saves you from having to patch the code every time.

  4. JokerCatz commented at 6:31 PM on March 23, 2016: none

    Hi @laanwj , yes I need SelectCoins , & I know how to send a raw transactions , but I don't know how to calculate transaction fees I need to pay ... I know the rule

    https://en.bitcoin.it/wiki/Transaction_fees#Technical_info

    but I can't find examples to show how to send it with bitcoin core , like get "input_age" , "bytes" or another attributes & calculate current transaction fees ...

  5. MarcoFalke commented at 11:19 PM on March 23, 2016: member

    https://en.bitcoin.it/wiki/Transaction_fees#Technical_info

    This is overly outdated. Someone should rework this page thoroughly. Other than that you can just create the raw transaction how you wish and then pipe it through fundrawtransaction to create the change output and calculate the fee (just as when sending "normally").

  6. promag commented at 11:32 PM on March 23, 2016: member

    I think you can:

    1. listunspent
    2. choose the unspents to use as inputs to createrawtransaction
    3. call fundrawtransaction to complete the transaction, which adds the fee
    4. sign and send the transaction
  7. JokerCatz commented at 2:28 AM on March 24, 2016: none

    okay , I got it and many thanx : )

  8. JokerCatz commented at 7:01 AM on March 24, 2016: none

    Hi , I tried fundrawtransaction is very useful , but it seen not set paytxfee / mintxfee / txconfirmtarget & my bitcoin core send fees : 0.00002260

    bitcoin core ver 0.12

    start with : bitcoind -daemon -paytxfee=0.0001 -mintxfee=0.0001 -txconfirmtarget=25 ~/.bitcoin/bitcoin.conf has

     paytxfee=0.0001
     mintxfee=0.0001
     txconfirmtarget=25
    

    and bitcoin-cli getinfo

    {
      "version": 120000,
      "protocolversion": 70012,
      "walletversion": 60000,
      "balance": SKIP,
      "blocks": 404037,
      "timeoffset": 0,
      "connections": 2,
      "proxy": "",
      "difficulty": 165496835118.2263,
      "testnet": false,
      "keypoololdest": 1457072755,
      "keypoolsize": 301,
      "paytxfee": 0.00010000,
      "relayfee": 0.00001000,
      "errors": ""
    }
    

    and transaction

    bitcoin-cli sendtoaddress 1HgMYCCqTEnFNa4Q7BMiMQTd7hNCicL6cQ 0.01
    > bce0faa65a74c96d0f9d49d29dbdf211b208b587d7c93e3e2ef0639aad74a520
    bitcoin-cli gettransaction bce0faa65a74c96d0f9d49d29dbdf211b208b587d7c93e3e2ef0639aad74a520
    {
      "amount": -0.01000000,
      "fee": -0.00002260,
      "confirmations": 0,
      "trusted": true,
      "txid": "bce0faa65a74c96d0f9d49d29dbdf211b208b587d7c93e3e2ef0639aad74a520",
      "walletconflicts": [],
      "time": 1458802635,
      "timereceived": 1458802635,
      "bip125-replaceable": "no",
      "details": [
        {
          "account": "",
          "address": "1HgMYCCqTEnFNa4Q7BMiMQTd7hNCicL6cQ",
          "category": "send",
          "amount": -0.01000000,
          "vout": 0,
          "fee": -0.00002260
        }
      ],
      "hex": SKIP
    }
    

    is ver 0.12 set default fees or is a bug? even I set paytxfee / mintxfee / txconfirmtarget or I get something wrong? blockchain.info show this transaction "Transaction rejected by our node. Reason: The transaction is not final" , I tried remove txconfirmtarget option is same...

  9. laanwj commented at 8:04 AM on March 24, 2016: member

    but I can't find examples to show how to send it with bitcoin core , like get "input_age" , "bytes" or another attributes & calculate current transaction fees ...

    Those are no longer relevant for fee computation, just the size of the transaction in kB. fundrawtransaction has already been explained above. But at the lowest level you can use estimatefee N to estimate the current fee that is necessary per kB, to get the transaction confirmed within N blocks. From that, and your transaction size, you can compute the fee.

    is ver 0.12 set default fees or is a bug? even I set paytxfee / mintxfee / txconfirmtarget

    There is no use in specifying both paytxfee and txconfirmtarget. Specifying a paytxfee disables use of the the automatic fee estimation, and sets a fixed fee per kB for wallet transactions.

  10. JokerCatz commented at 9:39 AM on March 24, 2016: none

    okay , I got it , I will start upgrade my production to ver 0.12 and send raw transaction to fix dust merge , thanx all , dev team , the new raw transaction functions is very useful : )

  11. paveljanik commented at 7:27 AM on March 29, 2016: contributor

    @JokerCatz OK, good to hear your problem is fixed. Can you please close the issue now?

  12. JokerCatz commented at 1:41 AM on March 30, 2016: none

    okay~ sure : )

  13. JokerCatz closed this on Mar 30, 2016

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

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