Skip to content

Conversation

@morcos
Copy link
Contributor

@morcos morcos commented Jul 27, 2017

I'm not sure if this is the cause of the issue in #10034 , but this was a known edge case. I just didn't realize how simple the fix is.

Could use a couple more eyes to make sure nothing silly can go wrong here, but if we all agree it's this simple, we can add this as another 0.15 bug fix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit, nSubtractFeeFromAmount > 0.

Copy link
Contributor

@promag promag Jul 27, 2017

Choose a reason for hiding this comment

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

nFeeRet == 0 should not be necessary? So the first iteration should have enough inputs for when nSubtractFeeFromAmount > 0, or am I missing something?

Copy link
Contributor

@promag promag Jul 27, 2017

Choose a reason for hiding this comment

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

Actually, because of

                    // Never create dust outputs; if we would, just
                    // add the dust to the fee.
                    if (IsDust(newTxOut, discard_rate))
                    {
                        nChangePosInOut = -1;
                        nFeeRet += nChange;
                    }

nFeeRet can be > 0, and in that case there is no need to pick new inputs too.

Copy link
Contributor Author

@morcos morcos Jul 28, 2017

Choose a reason for hiding this comment

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

Good catch. The nFeeRet == 0 check wasn't really doing anything useful anyway, because pick_new_inputs doesn't ever get reset to true. But the prior check that I edited the comment on asserts that we are always on our final pass if pick_new_inputs is false.

@promag
Copy link
Contributor

promag commented Jul 28, 2017

utACK 49d903e.

@instagibbs
Copy link
Member

utACK 49d903e

@sipa
Copy link
Member

sipa commented Jul 31, 2017

Concept ACK

1 similar comment
@Leviathn
Copy link

Concept ACK

@laanwj
Copy link
Member

laanwj commented Aug 1, 2017

utACK 49d903e, looks sane to me

@sdaftuar
Copy link
Member

sdaftuar commented Aug 2, 2017

utACK; agree this would be good to include in 0.15 as a bugfix.

Perhaps edit the PR description to explain this a bit better (as that is now included in the merge commit)?

@TheBlueMatt
Copy link
Contributor

utACK, it would be good to clean this function up to calculate change output after calculating the fee at some point post-15.

Copy link
Contributor

@gmaxwell gmaxwell left a comment

Choose a reason for hiding this comment

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

utACK

@jonasschnelli
Copy link
Contributor

utACK 49d903e

@laanwj laanwj merged commit 49d903e into bitcoin:master Aug 3, 2017
laanwj added a commit that referenced this pull request Aug 3, 2017
… from recipients

49d903e Eliminate fee overpaying edge case when subtracting fee from recipients (Alex Morcos)

Pull request description:

  I'm not sure if this is the cause of the issue in #10034 , but this was a known edge case.  I just didn't realize how simple the fix is.

  Could use a couple more eyes to make sure nothing silly can go wrong here, but if we all agree it's this simple, we can add this as another 0.15 bug fix.

Tree-SHA512: db1dd1e83363a3c231267b626d3a388893ee70ba1972056fe2c339c5c9e4fbfd30f7fe837c30cc7be884d454797fd4c619b9d631a8d5eeb55cdb07402a83acb3
PastaPastaPasta pushed a commit to PastaPastaPasta/dash that referenced this pull request Aug 12, 2019
…ing fee from recipients

49d903e Eliminate fee overpaying edge case when subtracting fee from recipients (Alex Morcos)

Pull request description:

  I'm not sure if this is the cause of the issue in bitcoin#10034 , but this was a known edge case.  I just didn't realize how simple the fix is.

  Could use a couple more eyes to make sure nothing silly can go wrong here, but if we all agree it's this simple, we can add this as another 0.15 bug fix.

Tree-SHA512: db1dd1e83363a3c231267b626d3a388893ee70ba1972056fe2c339c5c9e4fbfd30f7fe837c30cc7be884d454797fd4c619b9d631a8d5eeb55cdb07402a83acb3
@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

Development

Successfully merging this pull request may close these issues.