HomePhabricator

Merge #10712: Add change output if necessary to reduce excess fee

Description

Merge #10712: Add change output if necessary to reduce excess fee

Summary:
0f402b9 Fix rare edge case of paying too many fees when transaction has no change. (Alex Morcos)
253cd7e Only reserve key for scriptChange once in CreateTransaction (Alex Morcos)

Pull request description:

This is an alternative to #10333

See commit messages.

The first commit is mostly code move, it just moves the change creation code out of the loop.

@instagibbs

Tree-SHA512: f16287ae0f0c6f09cf8b1f0db5880bb567ffa74a50898e3d1ef549ba592c6309ae1a9b251739f63a8bb622d48f03ce2dff9e7a57a6bac4afb4b95b0a86613ea8

Backport of Core PR10712
https://github.com/bitcoin/bitcoin/pull/10712/commits
Completes T534

Test Plan:

make check
test_runner.py

Reviewers: deadalnix, Fabien, #bitcoin_abc

Reviewed By: deadalnix, #bitcoin_abc

Subscribers: teamcity, schancel

Differential Revision: https://reviews.bitcoinabc.org/D2503