bitcoin-cli fundrawtransaction crashes bitcoind #14634

issue NicosKaralis opened this issue on November 1, 2018
  1. NicosKaralis commented at 6:53 PM on November 1, 2018: none

    <!-- This issue tracker is only for technical issues related to Bitcoin Core. General bitcoin questions and/or support requests are best directed to the Bitcoin StackExchange at https://bitcoin.stackexchange.com. For reporting security issues, please read instructions at https://bitcoincore.org/en/contact/. If the node is "stuck" during sync or giving "block checksum mismatch" errors, please ensure your hardware is stable by running memtest and observe CPU temperature with a load-test tool such as linpack before creating an issue! -->

    <!-- Describe the issue -->

    I've updated from 0.16 to 0.17 and I'm trying to create a raw transaction to be signed on an offline wallet. This used to work fine, but now it doesn't.

    I'm creating a raw transaction with createrawtransaction with no inputs and the desired output. I'm using the hex generated in fundrawtransaction to match inputs.

    Since the online wallet is watch only I need to pass includeWatching in params. Also I want to send the change amount to a different address, so I added changeAddress to the options hash. This command kills the entire bitcoind process with no warnings and no log messages

    This is the commands I've tried and their output:

    $ bitcoin-cli createrawtransaction '[]' '{"14XbnUUvc2Kt8TrnnEG9zjF1XM2jYD1h8x":0.001}'
    020000000001a0860100000000001976a91426b1e477be0f7bc5e2cf12dd5b973e57e7fab5bf88ac00000000
    
    $ bitcoin-cli fundrawtransaction 020000000001a0860100000000001976a91426b1e477be0f7bc5e2cf12dd5b973e57e7fab5bf88ac00000000
    error code: -4
    error message:
    Insufficient funds
    
    $ bitcoin-cli fundrawtransaction 020000000001a0860100000000001976a91426b1e477be0f7bc5e2cf12dd5b973e57e7fab5bf88ac00000000 '{"includeWatching":true}'
    {
      "hex": "02000000016c4262fe490eb44becac4d4aa37f86b4433327ffa40a00a5498006c6ec5b0b240100000000feffffff02089a03000000000017a914ab7dd53603b6b64d3851569b90eeae8f39fd9f0087a0860100000000001976a91426b1e477be0f7bc5e2cf12dd5b973e57e7fab5bf88ac00000000",
      "fee": 0.00000675,
      "changepos": 0
    }
    
    $ bitcoin-cli fundrawtransaction 020000000001a0860100000000001976a91426b1e477be0f7bc5e2cf12dd5b973e57e7fab5bf88ac00000000 '{"includeWatching":true,"changeAddress":"185pJS3yVizdE3RtXKALtVbGRv9gzzypT1"}'
    error: Could not connect to the server 127.0.0.1:8332 (error code 1 - "EOF reached")
    
    Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
    

    After the last command the bitcoind is no longer running. This error happens every time if I add the changeAddress param.

    After looking for a solution in here I've found about gdb. After running gdb --args bitcoind -conf=/home/user/.bitcoin/bitcoin.conf I've got this error:

    bitcoind: policy/feerate.cpp:25: CAmount CFeeRate::GetFee(size_t) const: Assertion `nBytes_ <= uint64_t(std::numeric_limits<int64_t>::max())' failed.
    
    Thread 7 "bitcoin-httpwor" received signal SIGABRT, Aborted.
    [Switching to Thread 0x7fffebfff700 (LWP 22448)]
    __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
    51	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
    

    I will not append debug.log because it has no error. The process simply crashes. At first I was thinking this could be an out of memory. But after some digging I can safely say the problem is caused by policy/feerate.cpp#L14

  2. sipa commented at 7:32 PM on November 1, 2018: member

    @NicosKaralis This is a known issue, and a patch is available at #14380.

  3. NicosKaralis commented at 7:35 PM on November 1, 2018: none

    @sipa how do I use the patched version?

  4. sipa commented at 7:36 PM on November 1, 2018: member

    @NicosKaralis You'll need to build from source with that patch applied, or wait until a release which has the fix included (which will presumably be 0.17.1).

    There is also a workaround available, namely importing all pubkeys/redeemscripts/witnessscripts involved in the addresses you're watching (so they're "solvable", not just watched).

  5. NicosKaralis commented at 7:45 PM on November 1, 2018: none

    @sipa thanks for the quick reply

    I don't know how to build it from source. Could I install version 0.16.3 again? Because it was working (I'm using ubuntu and apt-get only shows 0.17)

    Also, I don't think I fully understand the workaround, to import the watch only addresses I'm using:

    bitcoin-cli importpubkey $PUB_KEY_HEX label false
    bitcoin-cli importaddress $P2WPKH_P2SH_ADDR label false

    Isn't this enough? In 0.16 this made my transaction solvable

  6. sipa commented at 7:48 PM on November 1, 2018: member

    @NicosKaralis You'll also need to import the P2WPKH script itself; I'm skeptical that in 0.16 those commands resulted in solvability.

  7. NicosKaralis commented at 7:53 PM on November 1, 2018: none

    @sipa Well, it is, if I manage to install 0.16.3 I'll report back.

    But about the P2WPKH script itself

    I'm using a ruby script to generate an HD wallet based on a given seed. The library does not have support for P2WPKH P2SH so I've hacked it and added. But I don't know how to generate or calculate the P2WPKH script itself

    Can you point me in the correct direction?

    And after I have the script, how do I import it to bitcoind?

  8. NicosKaralis commented at 8:08 PM on November 1, 2018: none

    Quick update. I've downloaded 0.16.3, simply ran from the unzipped folder with my configs and this is the result:

    bitcoin-cli createrawtransaction '[]' "{"14XbnUUvc2Kt8TrnnEG9zjF1XM2jYD1h8x":0.001}"
    $ 020000000001a0860100000000001976a91426b1e477be0f7bc5e2cf12dd5b973e57e7fab5bf88ac00000000
    bitcoin-cli fundrawtransaction $TX '{"changeAddress":"185pJS3yVizdE3RtXKALtVbGRv9gzzypT1","includeWatching":true,"feeRate":0.0001}'
    $ {"hex"=>"02000000016c4262fe490eb44becac4d4aa37f86b4433327ffa40a00a5498006c6ec5b0b240100000000feffffff02a0860100000000001976a91426b1e477be0f7bc5e2cf12dd5b973e57e7fab5bf88ac07960300000000001976a9144db207625bc6ac72bdf1879a71d17b381546728088ac00000000", "changepos"=>1, "fee"=>1.7e-05}
    

    And just because @sipa said I'm skeptical that in 0.16 those commands resulted in solvability. below is the listunspent output. I assume spendable is false because this wallet does not have private keys. And solvable is true (I think) its because it can be used on payments

    [
      {
        "txid": "240b5becc6068049a5000aa4ff273343b4867fa34a4dacec4bb40e49fe62426c",
        "vout": 1,
        "address": "3K98gTgpBT1iXA2jXChNVH2Gewp5K2BqG2",
        "account": "cold_deposits",
        "redeemScript": "0014d81509228d6a277ae8220f62416c0faf9231df1f",
        "scriptPubKey": "a914bf6a980d2e06f18957efd7cfb90f3e3cf519a7b287",
        "amount": 0.00336715,
        "confirmations": 330,
        "spendable": false,
        "solvable": true,
        "safe": true
      },
      {
        "txid": "62014e749527dbb7d22734cb46cc8b2f93b5b1bb4751ab4b500e3de4444b59df",
        "vout": 1,
        "address": "3H97SEok2J9eUiiWAxyu2KA9rjn1a8yUef",
        "account": "cold_deposits",
        "redeemScript": "0014878f5e235c9ae5a8f599fa3654bf4dcc6716a5f6",
        "scriptPubKey": "a914a9794d8d3799597ee6d2567c69e4300ccf30c89b87",
        "amount": 0.00028155,
        "confirmations": 334,
        "spendable": false,
        "solvable": true,
        "safe": true
      }
    ]
    

    EDIT

    And just because I'm happy, this is the transaction made: 40f3ca2ef6dc8fc1b3648e612d63fda43d43fc5559d0b3f89e51b7a3bcc73865

  9. sipa commented at 8:46 PM on November 1, 2018: member

    @NicosKaralis Interesting, does it report "solvable : true" for that unspent in 0.17 as well?

  10. NicosKaralis commented at 8:52 PM on November 1, 2018: none

    @sipa I'm sorry to say I did not check. After you said this is a 0.17 problem I just rush to downgrade my version (I'm on a tight deadline). I'll come back later, if no one checks I'll check and post here the findings

  11. fanquake commented at 11:25 PM on January 8, 2019: member

    Fixed in #14380.

  12. fanquake closed this on Jan 8, 2019

  13. MarcoFalke locked this on Dec 16, 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-05-11 18:15 UTC

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