Skip to content

Conversation

dooglus
Copy link
Contributor

@dooglus dooglus commented Nov 25, 2016

I notice it is now possible to have the fee subtracted from the output amounts by specifying a subtractFeeFromAmount parameter in both sendtoaddress and sendmany, but not in fundrawtransaction.

This commit adds the option to fundrawtransaction.

@gmaxwell
Copy link
Contributor

Concept ACK.

@jonasschnelli
Copy link
Contributor

Nice. Concept ACK.
Needs test.

@dooglus
Copy link
Contributor Author

dooglus commented Nov 26, 2016

@jonasschnelli I tried finding the fundrawtransaction tests but couldn't. Where are they?

src/test/rpc_tests.cpp seems like the natural place for them, but I see no 'fund' in there at all.

@jonasschnelli
Copy link
Contributor

@dooglus
There is one at ./qa/rpc-tests/fundrawtransaction.py.
The tests should make sure that the subtractFeeFromAmount option work in conjunction with the custom feerate option (haven't look at your code so far).

@dooglus
Copy link
Contributor Author

dooglus commented Nov 27, 2016

@jonasschnelli Thanks for pointing me at the qa/ directory. I hadn't noticed it before.

I have added tests for subtractFeeFromAmount, including checking that it works in combination with custom feerate.

@sipa
Copy link
Member

sipa commented Nov 28, 2016

Concept ACK

if (options.exists("subtractFeeFromAmount")) {
subtractFeeFromAmount = options["subtractFeeFromAmount"].get_array();
for (unsigned int idx = 0; idx < subtractFeeFromAmount.size(); idx++) {
string strAddress(subtractFeeFromAmount[idx].get_str());
Copy link
Contributor

Choose a reason for hiding this comment

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

This will thrown an exception if one of the elements in the array is numeric. But I think this is okay.

@jonasschnelli
Copy link
Contributor

Code Review ACK a979010c80d5875ab26c9cdd5401e2b2905dd572.
Squash required.

@dooglus
Copy link
Contributor Author

dooglus commented Nov 28, 2016

To 'squash' the commits do I just rewrite the same branch with a push --force? Or make a new branch and a new pull request?

@jonasschnelli
Copy link
Contributor

@dooglus: Yes. I normally do a git rebase -I head~<amount-of-commits>, find the commit you'd like to squash to and mark all later commits with a s. Then git push --force.

@dooglus dooglus force-pushed the subtractFeeFromAmount-in-fundraw branch from a979010 to 64955cf Compare November 28, 2016 08:17
@dooglus
Copy link
Contributor Author

dooglus commented Nov 28, 2016

@jonasschnelli Thanks. The 'i' is lowercase and the 'HEAD' is uppercase but it was close enough.

I used git rebase -i HEAD~3 and it appears to have worked.

@morcos
Copy link
Contributor

morcos commented Nov 28, 2016

utACK

assert(result[0]['fee'] == result[1]['fee'])
assert(result[0]['fee'] == result[2]['fee'])
assert(result[0]['fee'] == result[3]['fee'])
assert(result[4]['fee'] == result[5]['fee'])
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you can condense this to:
assert(result[0]['fee']==result[1]['fee']== result[2]['fee']==result[3]['fee'])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Interesting. I didn't know Python did that. I will do as you suggest.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 6a41954.


# change amounts in result 0, 1, and 2 are the same
assert(change[0] == change[1])
assert(change[0] == change[2])
Copy link
Contributor

Choose a reason for hiding this comment

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

same

Copy link
Contributor Author

@dooglus dooglus Nov 29, 2016

Choose a reason for hiding this comment

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

Yes. Addressed in 6a41954.

throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+strAddress);
if (setSubtractFeeFromAmount.count(strAddress))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+strAddress);
setSubtractFeeFromAmount.insert(strAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should it throw an error if the given address is valid but is not among the outputs? (would have to check for this below, after retrieving the transaction). It seems like in this case, the user is trying to pay the fee with one of the outputs but has made an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted it to behave the same as it does in sendmany, where it doesn't complain if you include an address that isn't a recipient at all.

The user could have a list of addresses which should pay fees when sent to, and use that same list as their subtractFeeFromAmount parameter whichever addresses they are sending to.

Copy link
Contributor

Choose a reason for hiding this comment

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

One difference between this and sendmany is that sendmany requires transaction outputs to be base58 addresses, and takes amounts and subtractfeefromamount arguments in base58 form, while fundrawtransaction allows outputs to be arbitrary scripts. This means with the PR in its current form, there may be no way for the new subtractFeeFromAmount argument to refer to certain outputs.

Instead of adding a subtractFeeFromAmount argument, I might suggest adding a subtractFeeFromPositions argument that takes a list of integer output indices. This would give callers the flexibility to refer to all outputs, be more consistent with the existing changePosition argument (which is also an integer output index), and also eliminate the need for ExtractDestination and CBitcoinAddress::ToString invocations in CWallet::FundTransaction.

Copy link
Member

Choose a reason for hiding this comment

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

@ryanofsky I like the idea but am a bit worried about the interaction of subtractFeeFromPositions and changePosition. It might not be clear to the user if the position marking is done before or after change output is added, or discount the wrong output by adding a changePosition argument.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the time of running fundrawtransaction there is no change output, and the user wouldn't know where the change will be inserted, so the position marking must be done before the change output is added.

I think since it is possible to add arbitrary hex output scripts which may not even have a corresponding address we need to be able to address the outputs by number rather than by address. It's also kind of ugly having to give the same address twice, once to createrawtransaction and then again to fundrawtransaction. I think using the output index (0 based) is cleaner.

Copy link
Member

@instagibbs instagibbs Dec 1, 2016

Choose a reason for hiding this comment

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

@dooglus the user will "know" where change is going if they attempt to set the change index they're setting in the option, which is my point. It's not plainly clear how this should interact, unless you spell it out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see. So I should spell it out...

I think it makes sense to use the position indices before the change output is added.

@dooglus
Copy link
Contributor Author

dooglus commented Nov 29, 2016

Addressed @mrbandrews' nits. Should I re-squash now, or leave the 'nit' commit separate for a while?

@morcos
Copy link
Contributor

morcos commented Nov 29, 2016

re-utACK 6a41954

@dooglus good question, its not always clear. I personally think that if the prior code is not broken , then its ok not to squash.

@jonasschnelli
Copy link
Contributor

utACK 6a41954895460a033afc352af5c137418591cc6b
@dooglus IMO squashing is not required when the commits has a reason to be separated. If it's just a trivial change/overhaul of the previous commit(s) in the PR, it should probably be squashed.

throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, string("Invalid Bitcoin address: ")+strAddress);
if (setSubtractFeeFromAmount.count(strAddress))
throw JSONRPCError(RPC_INVALID_PARAMETER, string("Invalid parameter, duplicated address: ")+strAddress);
setSubtractFeeFromAmount.insert(strAddress);
Copy link
Contributor

Choose a reason for hiding this comment

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

One difference between this and sendmany is that sendmany requires transaction outputs to be base58 addresses, and takes amounts and subtractfeefromamount arguments in base58 form, while fundrawtransaction allows outputs to be arbitrary scripts. This means with the PR in its current form, there may be no way for the new subtractFeeFromAmount argument to refer to certain outputs.

Instead of adding a subtractFeeFromAmount argument, I might suggest adding a subtractFeeFromPositions argument that takes a list of integer output indices. This would give callers the flexibility to refer to all outputs, be more consistent with the existing changePosition argument (which is also an integer output index), and also eliminate the need for ExtractDestination and CBitcoinAddress::ToString invocations in CWallet::FundTransaction.

@@ -2181,14 +2181,16 @@ bool CWallet::SelectCoins(const vector<COutput>& vAvailableCoins, const CAmount&
return res;
}

bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool overrideEstimatedFeeRate, const CFeeRate& specificFeeRate, int& nChangePosInOut, std::string& strFailReason, bool includeWatching, bool lockUnspents, const CTxDestination& destChange)
bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool overrideEstimatedFeeRate, const CFeeRate& specificFeeRate, int& nChangePosInOut, std::string& strFailReason, bool includeWatching, bool lockUnspents, std::set<std::string>& setSubtractFeeFromAmount, const CTxDestination& destChange)
Copy link
Contributor

Choose a reason for hiding this comment

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

Would suggest changing the new set<string> argument to set<int> to be consistent with the existing nChangePosInOut argument which refers to an output by integer index instead of base58 address string. This would give callers more flexibility in referring to outputs and also simplify handling of the new argument below.

" \"subtractFeeFromAmount\" (array, optional) A json array with addresses.\n"
" The fee will be equally deducted from the amount of each selected address.\n"
" Those recipients will receive less bitcoins than you enter in their corresponding amount field.\n"
" If no addresses are specified here, the sender pays the fee.\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe s/If no addresses are specified here/If no addresses specified here are outputs in the transaction

" \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n"
" \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n"
" \"feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific feerate (" + CURRENCY_UNIT + " per KB)\n"
" \"subtractFeeFromAmount\" (array, optional) A json array with addresses.\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe mention after This will not modify existing inputs, and will add one change output to the outputs above that no existing outputs will be modified either unless subtractFeeFromAmount is specified.

assert(output[0] == output[1] == output[2])

# 0's output should be equal to 3's (output plus fee)
assert(output[0] == output[3] + result[3]['fee'])
Copy link
Contributor

Choose a reason for hiding this comment

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

Debug output will be a little better if you use assert_equal instead of assert here and below.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It appears that assert_equal can only compare two things. For cases like assert(A == B == C == D) would you prefer 3 separate assert_equal() calls instead?

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense. In case something fails we have the verbose output.

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually only meant to suggest using assert_equal for binary comparisons like the one on line 698. But if you wanted to use it more broadly, you could extend the function (in util.py) to accept more arguments:

def assert_equal(thing1, thing2, *args):
    if thing1 != thing2 or any(thing1 != arg for arg in args):
        raise AssertionError("!(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it be better to extend assert_equal() to take an arbitrary number of parameters and have it compare them pairwise? Something like this would work:

def assert_equal(thing1, thing2, *other_things, depth=0):
    if thing1 != thing2:
        if depth or other_things:
            raise AssertionError("%s != %s (positions %d and %d)"%(str(thing1),str(thing2), depth, depth+1))
        else:
            raise AssertionError("%s != %s"%(str(thing1),str(thing2)))
    if other_things:
        assert_equal(thing2, *other_things, depth = depth + 1)

>>> assert_equal(4, 4, 5)
AssertionError: 4 != 5 (positions 1 and 2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I missed your last comment. Your solution is obviously much more elegant.

Is it acceptable to include a change like that in this pull request or should it be separate?

Copy link
Member

Choose a reason for hiding this comment

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

Fine to include it here.

self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 2*min_relay_tx_fee}),
self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 2*min_relay_tx_fee, "subtractFeeFromAmount": [addr1]})]

dec_tx = [self.nodes[3].decoderawtransaction(result[0]['hex']),
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use list comprehension:

dec_tx = [self.nodes[3].decoderawtransaction(tx['hex'] for tx in result]

assert(change[4] + result[4]['fee'] == change[5])

inputs = []
addr0 = self.nodes[2].getnewaddress()
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use dictionary comprehension:

outputs = {self.nodes[2].getnewaddress(): value for value in (1.0, 1.1, 1.2, 1.3)}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, thanks.

dec_tx[1]['vout'][3]['value'],
dec_tx[1]['vout'][4]['value']]]
del output[0][result[0]['changepos']]
del output[1][result[1]['changepos']]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use list comprehension:

output = [[out[value] for i, out in enumerate(d['vout']) if i != r['changepos']]
          for d, r in zip(dec_tx, result)]]

self.nodes[3].decoderawtransaction(result[4]['hex']),
self.nodes[3].decoderawtransaction(result[5]['hex'])]

output = [dec_tx[0]['vout'][1 - result[0]['changepos']]['value'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use list comprehension (and similarly below):

output = [d['vout'][1 - r['changepos']]['value'] for d, r in zip(dec_tx, result)]

@dooglus dooglus force-pushed the subtractFeeFromAmount-in-fundraw branch from 6a41954 to b0d3046 Compare December 6, 2016 08:02
@dooglus
Copy link
Contributor Author

dooglus commented Dec 6, 2016

I've addressed all the review comments, rebased, squashed, and pushed the resulting commit.

I'm wondering whether there's a potential issue with using integers to select which outputs to subtract the fee from, since the outputs are specified by a JSON dictionary, and dictionary keys are inherently unordered. Are we guaranteed when we createrawtransaction '[]' '{"a0":1,"a1":1,"a2":1}' that a<n> will be output <n>?

@dooglus dooglus force-pushed the subtractFeeFromAmount-in-fundraw branch 2 times, most recently from 8167931 to 56ea974 Compare December 6, 2016 08:09
@instagibbs
Copy link
Member

@dooglus good point, I don't think so. Recently ran into this writing extended rpc tests for something.

@dooglus
Copy link
Contributor Author

dooglus commented Dec 6, 2016

@instagibbs me too:

$ python3
Python 3.4.2

>>> [k for k in {'a':1,'b':2,'c':3,'d':1,'e':1,'f':1}]
['c', 'd', 'f', 'b', 'e', 'a']

Since the input to fundrawtransaction is a raw transaction with its outputs already serialized this is less of an issue. But I tend to string my RPC calls together and expect the outputs to be serialized in the order I type them to createrawtransaction. They always do seem to be in the correct order except when using Python.

@sipa
Copy link
Member

sipa commented Dec 6, 2016 via email

@maflcko
Copy link
Member

maflcko commented Dec 6, 2016

@dooglus For python you'd have to import OrderedDict (see #7980) but I don't think there is an ordered dict for json, so we should not rely on the order.

@dooglus
Copy link
Contributor Author

dooglus commented Dec 6, 2016

So we are saying that it's OK to use a list of integer indexes into the list of outputs because:

  1. by the time we're running fundrawtransaction the output list already has its order fixed (it's a raw transaction already, not a JSON object)
  2. we have no other way to refer to general outputs, since they can be arbitrary hex strings and may not even have a base58 address
  3. Bitcoin Core's use of univalue means that the JSON output list provided to createrawtransaction is always interpreted as an ordered dictionary anyway

Right?

(I tested point 3 as follows:

addr1=$(for x in {1..32}; do bitcoin-cli --testnet getnewaddress; done)
raw=$(bitcoin-cli --testnet createrawtransaction '[]' '{"'$(echo $addr1 | sed 's/ /":1,"/g')'":1}')
addr2=$(bitcoin-cli --testnet decoderawtransaction $raw | grep -E '^ {10}"' | cut -d'"' -f2)
echo $addr1 | sha1sum
echo $addr2 | sha1sum

and found that the outputs appear in the raw transaction in the same order as listed in the input to createrawtransaction)

@sipa
Copy link
Member

sipa commented Dec 6, 2016

I think reason (1) is enough to make position based indexing ok, and (2) strengthens it.

I don't think (3) is a good reason or something we should ever rely on. The only reason this is brought up is because createrawtransaction accepts an object to list the outputs. If strict ordering is expected there, perhaps we should change that argument from {"addr1":val1, "addr2":val2} to [["addr1",val1],["addr2",val2]] instead (in another PR).

@dooglus
Copy link
Contributor Author

dooglus commented Dec 7, 2016

@sipa I'll look into making such a change in a separate PR. Using an object for the outputs not only means we cannot guarantee the order of the outputs but also having the addresses as dictionary keys means we can't have multiple outputs with the same address, which I sometimes like to do to (example).

I assume it would be best to allow the current object format in addition to the new array format for backwards compatibility.

@morcos
Copy link
Contributor

morcos commented Dec 7, 2016

+1 on address reuse being a sometimes valuable tool

@dooglus
Copy link
Contributor Author

dooglus commented Dec 13, 2016

What happens next? I addressed all the comments. Is there something else I need to do?

Copy link
Contributor

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Change looks good as is, just left a few possible suggestions.

Lightly tested ACK 56ea97409349baaf064c6c2a9da0ba8bbe207f27.

@@ -2181,14 +2181,15 @@ bool CWallet::SelectCoins(const vector<COutput>& vAvailableCoins, const CAmount&
return res;
}

bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool overrideEstimatedFeeRate, const CFeeRate& specificFeeRate, int& nChangePosInOut, std::string& strFailReason, bool includeWatching, bool lockUnspents, const CTxDestination& destChange)
bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, bool overrideEstimatedFeeRate, const CFeeRate& specificFeeRate, int& nChangePosInOut, std::string& strFailReason, bool includeWatching, bool lockUnspents, std::set<int>& setSubtractFeeFromOutputs, const CTxDestination& destChange)
Copy link
Contributor

Choose a reason for hiding this comment

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

New argument looks like it could be const reference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed.

{
vector<CRecipient> vecSend;

// Turn the txout set into a CRecipient vector
BOOST_FOREACH(const CTxOut& txOut, tx.vout)
for (unsigned int idx = 0; idx < tx.vout.size(); idx++)
Copy link
Contributor

Choose a reason for hiding this comment

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

Little better to use size_t here instead of unsigned int.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

for (unsigned int idx = 0; idx < subtractFeeFromOutputs.size(); idx++) {
int pos = subtractFeeFromOutputs[idx].get_int();
if (setSubtractFeeFromOutputs.count(pos))
throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("%s%d", "Invalid parameter, duplicated position: ", pos));
Copy link
Contributor

Choose a reason for hiding this comment

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

Little unusual to use %s for the main string instead of strprintf("Invalid parameter, duplicated position: %d", pos)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely.

" \"includeWatching\" (boolean, optional, default false) Also select inputs which are watch only\n"
" \"lockUnspents\" (boolean, optional, default false) Lock selected unspent outputs\n"
" \"feeRate\" (numeric, optional, default not set: makes wallet determine the fee) Set a specific feerate (" + CURRENCY_UNIT + " per KB)\n"
" \"subtractFeeFromOutputs\" (array, optional) A json array of integers.\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just say an array instead of a json array, since the whole data structure is json.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree, but it appears that everywhere else we refer to 'json array' (see sendmany, addmultisigaddress, lockunspent, listunspent...). Nowhere (in rpcwallet.cpp at least) do we simply say 'an array'.

Will leave as 'json array' for the sake of consistency.

raise AssertionError("%s != %s"%(str(thing1),str(thing2)))
def assert_equal(thing1, thing2, *args):
if thing1 != thing2 or any(thing1 != arg for arg in args):
raise AssertionError("!(%s)" % " == ".join(str(arg) for arg in (thing1, thing2) + args))
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it is python not c, maybe replace ! with not

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't imagine who might have written that! ;)

Will change ! to not.


dec_tx = [self.nodes[3].decoderawtransaction(result[0]['hex']),
self.nodes[3].decoderawtransaction(result[1]['hex'])]

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add comment describing output, could be # Nested list of non-change output amounts for each transaction

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

output = [[out['value'] for i, out in enumerate(d['vout']) if i != r['changepos']]
for d, r in zip(dec_tx, result)]

share = [o0 - o1 for o0, o1 in zip(output[0], output[1])]
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add comment like # List of difference in output amounts between normal and subtractFee transactions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

assert_equal(result[0]['fee'], result[1]['fee'], result[2]['fee'])
assert_equal(result[3]['fee'], result[4]['fee'])

# change amounts in result 0 and 1 are the same
Copy link
Contributor

Choose a reason for hiding this comment

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

This and the 5 following comments are basically just describing the asserts without adding any information. Could maybe remove the comments and condense the asserts.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree.

@dooglus dooglus force-pushed the subtractFeeFromAmount-in-fundraw branch from 56ea974 to 453bda6 Compare December 13, 2016 21:38
@dooglus
Copy link
Contributor Author

dooglus commented Dec 13, 2016

Addressed @ryanofsky nits, rebased, squashed.

@ryanofsky
Copy link
Contributor

Lightly tested ACK 453bda6

luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Dec 21, 2016
@dooglus
Copy link
Contributor Author

dooglus commented Jan 2, 2017

Can this be merged now?

@laanwj laanwj merged commit 453bda6 into bitcoin:master Jan 12, 2017
laanwj added a commit that referenced this pull request Jan 12, 2017
453bda6 Add 'subtractFeeFromOutputs' option to 'fundrawtransaction'. (Chris Moore)
@ryanofsky
Copy link
Contributor

I'll look into making such a change in a separate PR. Using an object for the outputs not only means we cannot guarantee the order of the outputs but also having the addresses as dictionary keys means we can't have multiple outputs with the same address, which I sometimes like to do to (example).

#11872 was recently posted implementing this change.

@maflcko
Copy link
Member

maflcko commented Dec 14, 2017

Indeed. Though, note that the rpc currently rejects duplicate addresses, and that specific case is not changed in #11872.

codablock pushed a commit to codablock/dash that referenced this pull request Jan 21, 2018
…nsaction'.

453bda6 Add 'subtractFeeFromOutputs' option to 'fundrawtransaction'. (Chris Moore)
andvgal pushed a commit to energicryptocurrency/gen2-energi that referenced this pull request Jan 6, 2019
…nsaction'.

453bda6 Add 'subtractFeeFromOutputs' option to 'fundrawtransaction'. (Chris Moore)
CryptoCentric pushed a commit to absolute-community/absolute that referenced this pull request Feb 27, 2019
CryptoCentric pushed a commit to absolute-community/absolute that referenced this pull request Feb 27, 2019
…dablock committed on Jan 20, 2018 Use version 2 blocks for miner_tests … @codablock codablock committed on Jan 20, 2018   Merge bitcoin#7871: Manual block file pruning.  …  @laanwj @codablock laanwj authored and codablock committed on Jan 11, 2017   Merge bitcoin#9507: Fix use-after-free in CTxMemPool::removeConflicts()  …  @sipa @codablock sipa authored and codablock committed on Jan 11, 2017   Merge bitcoin#9297: Various RPC help outputs updated  …  @MarcoFalke @codablock MarcoFalke authored and codablock committed on Jan 12, 2017   Merge bitcoin#9416: travis: make distdir before make  …  @MarcoFalke @codablock MarcoFalke authored and codablock committed on Jan 12, 2017   Merge bitcoin#9520: Deprecate non-txindex getrawtransaction and bette…  …  @MarcoFalke @codablock MarcoFalke authored and codablock committed on Jan 12, 2017   Merge bitcoin#9518: Return height of last block pruned by pruneblockc…  …  @MarcoFalke @codablock MarcoFalke authored and codablock committed on Jan 12, 2017   Merge bitcoin#9472: Disentangle progress estimation from checkpoints …  …  @laanwj @codablock laanwj authored and codablock committed on Jan 12, 2017   Merge bitcoin#8883: Add all standard TXO types to bitcoin-tx  …  @laanwj @codablock laanwj authored and codablock committed on Jan 12, 2017   Merge bitcoin#9261: Add unstored orphans with rejected parents to rec…  …  @laanwj @codablock laanwj authored and codablock committed on Jan 12, 2017   Merge bitcoin#9468: [Depends] Dependency updates for 0.14.0  …  @laanwj @codablock laanwj authored and codablock committed on Jan 12, 2017   Merge bitcoin#9222: Add 'subtractFeeFromAmount' option to 'fundrawtra…  …  @laanwj @codablock laanwj authored and codablock committed on Jan 12, 2017   Merge bitcoin#9490: Replace FindLatestBefore used by importmuti with …  …  @sipa @codablock sipa authored and codablock committed on Jan 13, 2017   Merge bitcoin#9469: [depends] Qt 5.7.1  …  @laanwj @codablock laanwj authored and codablock committed on Jan 15, 2017   Merge bitcoin#9380: Separate different uses of minimum fees  …  @laanwj @codablock laanwj authored and codablock committed on Jan 16, 2017   Remove SegWit related code in dash-tx  @codablock codablock committed on Sep 21, 2017   Merge bitcoin#9561: Wake message handling thread when we receive a ne…  …  @sipa @codablock sipa authored and codablock committed on Jan 17, 2017   Merge bitcoin#9508: Remove unused Python imports  …  @MarcoFalke @codablock MarcoFalke authored and codablock committed on Jan 18, 2017   Merge bitcoin#9512: Fix various things -fsanitize complains about
@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.