Skip to content

Conversation

@jonasschnelli
Copy link
Contributor

Basic implementation of a new rpc call fundrawtransaction.
This call will fill a rawtransaction containing only vouts with unspent coins from the wallet.

Currently there is no way to return the CReserveKey to the keypool.

@jonasschnelli jonasschnelli force-pushed the 2014_12_fundtransaction branch from 62ef48e to 88de6ee Compare December 17, 2014 21:23
@jonasschnelli
Copy link
Contributor Author

As createrawtransactions with potential unspent vins, this call does not lock the coins somehow.

Copy link
Contributor

Choose a reason for hiding this comment

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

s/exiting/existing

@aalness
Copy link
Contributor

aalness commented Dec 18, 2014

ACK the idea. It seems useful.

@gmaxwell
Copy link
Contributor

Sweet. This should have a mechenism to also include watchonly coins.

@gmaxwell
Copy link
Contributor

It should support existing VINs, which are useful if you want to specifically spend a particular coin, but need more inputs to complete the txn. One reason you may want to do this is to achieve mutual exclusion with a prior transaction. If the existing vins are adequate it shouldn't add any more.

@kanzure
Copy link
Contributor

kanzure commented Dec 19, 2014

Also, not to pile on too much, but a "fundmany" would be neat as well (in addition to watchonly support in fundrawtransaction). This would be useful for batch coin selection, offline signing, and coinjoin. Plus, fundmany is not a huge jump from sendmany.

Also, gmaxwell proposed on IRC a limit=N parameter on fundrawtransaction?

@jonasschnelli jonasschnelli force-pushed the 2014_12_fundtransaction branch 3 times, most recently from e1ea764 to db8b682 Compare December 20, 2014 20:51
@jonasschnelli
Copy link
Contributor Author

Added support for existing VINs.
Now comes with an extensive test-script.

@gmaxwell the proposed limit parameter needs probably some brainwork first. See (http://bitcoinstats.com/irc/bitcoin-dev/logs/2014/12/20#l1419085131). Maybe another pull.

@jonasschnelli
Copy link
Contributor Author

Just fixed an issue in CreateTransaction which produced endless recursive loops. Travis should now be happy.

kanzure added a commit to kanzure/bitcoin that referenced this pull request Dec 22, 2014
Support watchonly in fundrawtransaction, CreateTransaction, SelectCoins
and coin selection in general.

Coin selection is exposed over RPC through fundrawtransaction, and
watchonly can be enabled by passing includeWatching true (defaults to
false).

fundrawtransaction will first attempt to fund a transaction without
using watchonly, even when includeWatching is enabled. When this fails,
an includeWatching attempt is made.

When an includeWatching attempt at coin selection is performed (in
CreateTransaction), and all watchonlys are consumed leaving no funds
available for a fee, then CreateTransaction will not include a fee in
the transaction.

Also, includeWatching tests (for fundrawtransaction).

See also: bitcoin#5503
src/wallet.cpp Outdated
Copy link
Member

Choose a reason for hiding this comment

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

s/temporary/temporarily

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Fixed.

@jonasschnelli jonasschnelli force-pushed the 2014_12_fundtransaction branch from 92dcfa0 to 1f8f85b Compare December 27, 2014 19:52
@laanwj laanwj added the Wallet label Feb 27, 2015
@laanwj laanwj added this to the 0.11.0 milestone Feb 27, 2015
@laanwj
Copy link
Member

laanwj commented Feb 27, 2015

needs rebase (assigned 0.11 milestone, would be nice to have this)

@jonasschnelli jonasschnelli force-pushed the 2014_12_fundtransaction branch from 1f8f85b to 0e093a7 Compare March 5, 2015 07:53
@jonasschnelli
Copy link
Contributor Author

rebased.

Moved RPC function "fundrawtransaction()" from rpcrawtransaction.cpp to rpcwallet.cpp (fundrawtransaction is a wallet function). Added wallet-is-presence check because we recently removed "reqWallet" check over the RPC dispatch table.

@jonasschnelli jonasschnelli force-pushed the 2014_12_fundtransaction branch 2 times, most recently from bcd0359 to 9ffa175 Compare April 20, 2015 13:46
- fix typo
- fix RPCTypeCheck for fundrawtransaction
- some comments
- merged with subtractFeeFromAmout patch (non trivial)
- serialize transaction size calculation (aka dummy-signing) without the need of signing the transaction (wallet can be locked to use fundrawtransaction)
- rename VINS to vInputs
fundrawtransaction requires a wallet and therefore it belongs to rpcwallet.cpp
rpc dispatch tables reqWallet has been removed.
@jonasschnelli jonasschnelli force-pushed the 2014_12_fundtransaction branch from 9ffa175 to 79858cd Compare April 21, 2015 18:25
@jonasschnelli
Copy link
Contributor Author

rebased.

@TheBlueMatt
Copy link
Contributor

I needed to use this for something and rewrote/tweaked a few chunks. See changes at https://github.com/TheBlueMatt/bitcoin/tree/frt

@jonasschnelli
Copy link
Contributor Author

Pulled in some commits from @TheBlueMatt. Only pulled in clear beneficial and easy reviewable commits. Other things (CCoinControl usage, watch-only support) may be better handled in a 2nd pull request to avoid large changeset.

@jonasschnelli jonasschnelli force-pushed the 2014_12_fundtransaction branch from f1e48f4 to 840b89b Compare April 24, 2015 09:19
@TheBlueMatt
Copy link
Contributor

@jonasschnelli Actually, the changes I made were mostly to limit the size of this pull request. Some of them look like it would become a big pull request, but once squashed, the total size is actually smaller than the original :)

@TheBlueMatt
Copy link
Contributor

Also, not sure when you pulled in, but I force pushe'd a few times, you may want to check that the ones you merged are the latest versions (I'm done now, I think). I also merged in a tweaked-up version of fundrawtransaction there.

@jonasschnelli
Copy link
Contributor Author

@TheBlueMatt Thank you for your tweaks! Will try to go through the optimizing commits but need a clear head for that. Will do it soon.

@TheBlueMatt
Copy link
Contributor

I added two more commits to that tree and made a nice rebased version at https://github.com/TheBlueMatt/bitcoin/commits/frt2

@TheBlueMatt
Copy link
Contributor

Rebased frt2. @jonasschnelli do you want to review my changes and merge them here, or should I just open a new pull request? I'd like to keep this moving.

@TheBlueMatt TheBlueMatt mentioned this pull request Apr 30, 2015
@jonasschnelli
Copy link
Contributor Author

closing in favor of #6088

TheBlueMatt pushed a commit to TheBlueMatt/bitcoin that referenced this pull request Oct 20, 2015
Support watchonly in fundrawtransaction, CreateTransaction, SelectCoins
and coin selection in general.

Coin selection is exposed over RPC through fundrawtransaction, and
watchonly can be enabled by passing includeWatching true (defaults to
false).

fundrawtransaction will first attempt to fund a transaction without
using watchonly, even when includeWatching is enabled. When this fails,
an includeWatching attempt is made.

When an includeWatching attempt at coin selection is performed (in
CreateTransaction), and all watchonlys are consumed leaving no funds
available for a fee, then CreateTransaction will not include a fee in
the transaction.

Also, includeWatching tests (for fundrawtransaction).

See also: bitcoin#5503
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants