[RPC] Add import/removeprunedfunds rpc call #7558

pull instagibbs wants to merge 2 commits into bitcoin:master from instagibbs:prunedforport changing 13 files +351 −23
  1. instagibbs commented at 1:13 AM on February 19, 2016: member

    This allows wallets to import funds without a rescan. It required an address or private key to exist in the wallet before calling. Primarily to be used to import funds to a pruned wallet, but could be used in conjunction with importaddress/privkey without rescan on an archival node.

    A companion RPC call "removeprunedfunds" is added to allow the user to delete erroneous imported funds.

  2. instagibbs renamed this:
    Add importprunedfunds rpc call
    [RPC] Add importprunedfunds rpc call
    on Feb 19, 2016
  3. gmaxwell commented at 1:47 AM on February 19, 2016: contributor

    Concept ACK.

    What happens if I import a fully spent transaction but fail to import the transaction(s) spending it's outputs?

  4. sipa commented at 1:48 AM on February 19, 2016: member

    What happens if I import a fully spent transaction but fail to import the transaction(s) spending it's outputs?

    You are eaten by a grue.

  5. gmaxwell commented at 1:58 AM on February 19, 2016: contributor

    One could avoid the grue eating by using a lantern, I mean, checking if the output is still spendable and setting a flag... perhaps?

  6. paveljanik commented at 7:21 AM on February 19, 2016: contributor

    The build fails with this on some systems:

    /bin/sh: 1: /home/travis/build/bitcoin/bitcoin/bitcoin-i686-pc-linux-gnu/qa/rpc-tests/importprunedfunds.py: Permission denied
    
  7. laanwj commented at 9:53 AM on February 19, 2016: member

    Concept ACK, +1 for the grue

  8. jonasschnelli added the label Wallet on Feb 19, 2016
  9. in src/wallet/rpcdump.cpp:None in f9c0c0eca0 outdated
     253 | +    if (fHelp || params.size() < 2 || params.size() > 3)
     254 | +        throw runtime_error(
     255 | +            "importprunedfunds\n"
     256 | +            "\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets.\n"
     257 | +            "\nArguments:\n"
     258 | +            "1. \"rawtransaction\" (string, hex, required) A raw transaction funding an already-existing address in wallet\n"
    


    jonasschnelli commented at 12:46 PM on February 19, 2016:

    nit: (string, required) would be the pattern that matches with other rpc commands help. Hex as string type is mostly mentioned in the parameters description.

  10. jonasschnelli commented at 12:50 PM on February 19, 2016: contributor

    Nice and clean PR. Concept ACK.

  11. jonasschnelli commented at 1:24 PM on February 19, 2016: contributor

    And @paveljanik is right: importprunedfunds.py needs a -rwxr-xr-x file permissions mode.

  12. instagibbs force-pushed on Feb 19, 2016
  13. instagibbs commented at 8:06 PM on February 19, 2016: member

    @sipa @gmaxwell

    Seems the easiest way to do this is mark outputs as spent or not, and modify all functions which tally funds to account for this. For now the wallet simply checks if things are spent by looking through its wallet and looking for spends.

  14. instagibbs commented at 8:16 PM on February 19, 2016: member

    Alternatively, when computing available funds we can check if each output is available directly in the utxo set, rather than (just?) looking at wallet transactions.

    I don't know the internals well enough to know which is best, or if these are both terrible ideas. Especially in the presence of reorgs.

  15. sipa commented at 8:32 PM on February 19, 2016: member

    Marking outputs as spent is very complicated, as spendability depends on whether other transactions exist that spend them, which themselves may be in conflict with the blockchain.

    We can check the UTXO set for spendability in theory, but that introduces yet another dependency between the wallet and the node, and is something that fundamentally requires a trusted full node.

    IMHO, if you're manually importing transactions, you're bypassing the entire sync mechanism, it's your responsibility to also import whatever other transactions that may be relevant.

  16. instagibbs commented at 8:38 PM on February 19, 2016: member

    That was my feeling after digging around and thinking about it. On Feb 19, 2016 12:33 PM, "Pieter Wuille" notifications@github.com wrote:

    Marking outputs as spent is very complicated, as spendability depends on whether other transactions exist that spend them, which themselves may be in conflict with the blockchain.

    We can check the UTXO set for spendability in theory, but that introduces yet another dependency between the wallet and the node, and is something that fundamentally requires a trusted full node.

    IMHO, if you're manually importing transactions, you're bypassing the entire sync mechanism, it's your responsibility to also import whatever other transactions that may be relevant.

    — Reply to this email directly or view it on GitHub #7558 (comment).

  17. instagibbs force-pushed on Feb 25, 2016
  18. instagibbs cross-referenced this on Feb 25, 2016 from issue [WIP] [RPC] Add call zaptransaction to delete transaction from wallet by instagibbs
  19. instagibbs commented at 1:53 PM on March 7, 2016: member

    Added a companion RPC call to allow removal of imported transactions.

  20. instagibbs renamed this:
    [RPC] Add importprunedfunds rpc call
    [RPC] Add import/removeprunedfunds rpc call
    on Mar 7, 2016
  21. laanwj commented at 2:43 PM on March 7, 2016: member

    Added a companion RPC call to allow removal of imported transactions.

    Nice!

  22. instagibbs commented at 6:58 PM on March 10, 2016: member

    Fixed the undefined behavior that was causing the test to throw an error.

  23. instagibbs force-pushed on Mar 14, 2016
  24. instagibbs commented at 2:01 PM on March 14, 2016: member

    Squashed.

  25. Add importprunedfunds rpc call 7eb702954e
  26. Added companion removeprunedfunds call. f1bb13c93d
  27. instagibbs force-pushed on Mar 23, 2016
  28. instagibbs commented at 2:50 PM on March 23, 2016: member

    rebased

  29. laanwj commented at 9:15 AM on March 29, 2016: member

    utACK 7eb7029

  30. laanwj merged this on Mar 29, 2016
  31. laanwj closed this on Mar 29, 2016

  32. laanwj referenced this in commit b35a591793 on Mar 29, 2016
  33. laanwj cross-referenced this on Mar 29, 2016 from issue Add importmulti RPC call by pedrobranco
  34. jonasschnelli cross-referenced this on Mar 29, 2016 from issue [qa] Don't run pruning.py twice by MarcoFalke
  35. laanwj cross-referenced this on Mar 30, 2016 from issue TODO for release notes 0.13.0 by laanwj
  36. codablock referenced this in commit d0c1efa98e on Sep 16, 2017
  37. codablock referenced this in commit ba478f4746 on Sep 19, 2017
  38. codablock referenced this in commit 0c8de19050 on Dec 9, 2017
  39. codablock referenced this in commit e2fefa539d on Dec 19, 2017
  40. dagurval cross-referenced this on Jun 13, 2018 from issue Merkleblock tests and refactor by dagurval
  41. bitcoin 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-05-20 06:55 UTC