Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RPC] Add import/removeprunedfunds rpc call #7558

Merged
merged 2 commits into from Mar 29, 2016
Merged

Conversation

@instagibbs
Copy link
Member

@instagibbs instagibbs commented Feb 19, 2016

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.

@instagibbs instagibbs changed the title Add importprunedfunds rpc call [RPC] Add importprunedfunds rpc call Feb 19, 2016
@gmaxwell
Copy link
Contributor

@gmaxwell gmaxwell commented Feb 19, 2016

Concept ACK.

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

Loading

@sipa
Copy link
Member

@sipa sipa commented Feb 19, 2016

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.

Loading

@gmaxwell
Copy link
Contributor

@gmaxwell gmaxwell commented Feb 19, 2016

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

Loading

@paveljanik
Copy link
Contributor

@paveljanik paveljanik commented Feb 19, 2016

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

Loading

@laanwj
Copy link
Member

@laanwj laanwj commented Feb 19, 2016

Concept ACK, +1 for the grue

Loading

"importprunedfunds\n"
"\nImports funds without rescan. Corresponding address or script must previously be included in wallet. Aimed towards pruned wallets.\n"
"\nArguments:\n"
"1. \"rawtransaction\" (string, hex, required) A raw transaction funding an already-existing address in wallet\n"
Copy link
Contributor

@jonasschnelli jonasschnelli Feb 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Loading

@jonasschnelli
Copy link
Contributor

@jonasschnelli jonasschnelli commented Feb 19, 2016

Nice and clean PR.
Concept ACK.

Loading

@jonasschnelli
Copy link
Contributor

@jonasschnelli jonasschnelli commented Feb 19, 2016

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

Loading

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Feb 19, 2016

@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.

Loading

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Feb 19, 2016

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.

Loading

@sipa
Copy link
Member

@sipa sipa commented Feb 19, 2016

Loading

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Feb 19, 2016

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).

Loading

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Mar 7, 2016

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

Loading

@instagibbs instagibbs changed the title [RPC] Add importprunedfunds rpc call [RPC] Add import/removeprunedfunds rpc call Mar 7, 2016
@laanwj
Copy link
Member

@laanwj laanwj commented Mar 7, 2016

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

Nice!

Loading

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Mar 10, 2016

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

Loading

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Mar 14, 2016

Squashed.

Loading

@instagibbs
Copy link
Member Author

@instagibbs instagibbs commented Mar 23, 2016

rebased

Loading

@laanwj
Copy link
Member

@laanwj laanwj commented Mar 29, 2016

utACK 7eb7029

Loading

@laanwj laanwj merged commit f1bb13c into bitcoin:master Mar 29, 2016
1 check passed
Loading
laanwj added a commit that referenced this issue Mar 29, 2016
f1bb13c Added companion removeprunedfunds call. (instagibbs)
7eb7029 Add importprunedfunds rpc call (instagibbs)
@laanwj laanwj mentioned this pull request Mar 29, 2016
@laanwj laanwj mentioned this pull request Mar 30, 2016
16 tasks
codablock added a commit to codablock/dash that referenced this issue Dec 19, 2017
f1bb13c Added companion removeprunedfunds call. (instagibbs)
7eb7029 Add importprunedfunds rpc call (instagibbs)
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

6 participants