Skip to content

Conversation

@kallewoof
Copy link
Contributor

@kallewoof kallewoof commented Jan 5, 2018

No description provided.

@fanquake fanquake added the Wallet label Jan 5, 2018
@promag
Copy link
Contributor

promag commented Jan 5, 2018

Missing test.

@sipa
Copy link
Member

sipa commented Jan 5, 2018

This decreases the output? In some cases that may desirable, but in general I think that's very unexpected (I would think it would add a new input instead).

@kallewoof
Copy link
Contributor Author

If you don't have a change address chance are fairly high that you're simply moving coins (e.g. between wallets). Especially if you only have one utxo in, you may not want to associate other utxo's with it for privacy reasons.

@wtogami
Copy link
Contributor

wtogami commented Jan 5, 2018

"single output transactions are special in that the exact amount doesn't usually matter (the user is emptying a wallet or using coin control to move UTXOs)."

I would argue that this is not stated strongly enough. If they previously paid to a single output then it is almost always true that they do not care about the particular amount. This is especially true as the previous amount was subject to an arbitrary, variable fee.

Valid use cases where this behavior is necessary, where you really don't want to require adding more inputs in order to bumpfee:

  • Emptying a wallet
  • Emptying particular UTXO's

I would further suggest if the receiver was expecting a particular amount then you would expect there to be a change output.

@sipa
Copy link
Member

sipa commented Jan 5, 2018

@kallewoof You're right that in most cases right now that you don't care about the amount if there is only one output, but there is certainly no guarantee. The coin selection algorithm even explicitly tries to find a solution without change first - it's just pretty terrible at its job current (#10637 will make it succeed much more often).

@ryanofsky
Copy link
Contributor

ryanofsky commented Jan 5, 2018

I think this could be generalized and also be made safer by adding an reduce_output option to bumpfee (could also call it something like output_number or txout). This way you'd be able to bump single output transactions by specifying reduce_output: 0, but there'd be no risk of someone accidentally decreasing the amount they are trying to send by bumping the fee in other cases.

@kallewoof
Copy link
Contributor Author

kallewoof commented Jan 5, 2018

I don't think it makes sense to arbitrarily add inputs to bumpfee. I don't even know if RBF allows it (since you're suggesting it, I guess it does -- I thought I tried and failed).

Maybe a bump_from_output flag in options that did this behavior.

Edit: @ryanofsky That looks good to me.

@sipa
Copy link
Member

sipa commented Jan 5, 2018

I don't see why RBF wouldn't allow it, as long as all transactions you're replacing have been marked as replaceable.

I like the idea of explicitly marking an output that can be reduced.

Over time (especially after #10637), I think we'll inevitably need a way to bump transactions that don't have change. Depending on feerates and your wallet's UTXO set distribution, a large fraction of transactions may be created without change.

@instagibbs
Copy link
Member

does the wallet track which outputs had subtractFeeFromOutput? In that case further reduction seems completely fine as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

Check new output is less than 0.00099?

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, good point - fixing.

@promag
Copy link
Contributor

promag commented Jan 5, 2018

Agree that there are cases where the output(s) can't be reduced. In the cases it can be reduced, should it be re-funded?

@sdaftuar
Copy link
Member

sdaftuar commented Jan 5, 2018

I don't think it makes sense to arbitrarily add inputs to bumpfee. I don't even know if RBF allows it (since you're suggesting it, I guess it does -- I thought I tried and failed).

@kallewoof Currently our relay policy (and BIP 125) require that if you add a new input, it must be already confirmed -- perhaps you tested with an unconfirmed input?

(The idea behind that requirement was to ensure the new transaction was more likely to be mined than the ones it was replacing; now that we use ancestor feerate mining, we could perhaps relax this requirement and compare ancestor feerates of everything instead to ensure the new transaction has a higher mining score.)

@jtimon
Copy link
Contributor

jtimon commented Jan 8, 2018

concept ack after the current coin selection stop trying 1 output (I assume #10637 solves that?).

@gmaxwell
Copy link
Contributor

gmaxwell commented Jan 8, 2018

NAK. The only time it would be acceptable to reduce the output is if the transaction was created as subtract fee from output. Bumping should add additional inputs as required.

@promag
Copy link
Contributor

promag commented Jan 8, 2018

@gmaxwell even with an option to allow the subtract, default to false (since there is no subtract from output record)?

@gmaxwell
Copy link
Contributor

gmaxwell commented Jan 8, 2018

if it were behind a bunch of warnings, ... but even though if substract from wasn't initially selected should only be a last resort if it can't bump otherwise. The wallet shouldn't quietly direct the user into behavior that might cause them to get criminally prosecuted.

@gmaxwell
Copy link
Contributor

gmaxwell commented Jan 9, 2018

@wtogami The wallet has explicit information about transactions created where the user requested subtracting fees from amounts. Using that information would be fine but you cannot use the lack of a change output to detect this, when 2^inputs * fees_saved_from_excluding_an_output is large relative to the amount being paid an exact match frequently exists. And the PR pieter linked to will usually find it.

@kallewoof
Copy link
Contributor Author

Summary:

  • Do not implicitly assume a single-output-no-change transaction can be altered due to better coin selection in the future.
  • Require the user to select the output if the user does not want additional inputs to be added to cover increased fees.
  • (Allow adding additional inputs to cover increased fees -- separate PR)

For this PR, that translates to:

  • Fail if no output is explicitly chosen (pre-merge behavior)
  • Reduce single output to cover fees if user has explicitly picked it
  • Allow user to arbitrarily pick the output that is reduced for existing multi-output transactions (i.e. not restricted to change output).

@kallewoof kallewoof force-pushed the better-bumpfee branch 4 times, most recently from d75d90b to 861d605 Compare January 9, 2018 09:57
@kallewoof kallewoof changed the title [rpc] [wallet] Allow single-output transactions in bumpfee [rpc] [wallet] Allow specifying the output index when using bumpfee Jan 9, 2018
@kallewoof
Copy link
Contributor Author

kallewoof commented Jan 9, 2018

  • Self-review: RPC command help needs update to reflect change

Copy link
Member

Choose a reason for hiding this comment

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

This error will also display in the gui. Not sure if it makes sense there to mention reduce_output

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

Copy link
Member

Choose a reason for hiding this comment

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

It also sounds confusing when there isn't a single output?

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'll just revert it.

Copy link
Member

Choose a reason for hiding this comment

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

This will segfault on OOB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. Added bounds check in feebumper::CreateTransaction.

Copy link
Contributor

Choose a reason for hiding this comment

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

Where?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also add assert_raises_rpc_error tests for:

  • when not a number;
  • when reduce_output < 0 and >= len(vout).

For instance, see 7f67dd0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No idea how that happened, but my changes are gone. Fixing, again.

Copy link
Member

Choose a reason for hiding this comment

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

Needs a lower bounds check here too, to avoid accepting -1.

Copy link
Member

Choose a reason for hiding this comment

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

Nit: Extra space on the end

Copy link
Member

Choose a reason for hiding this comment

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

CreateTotalBumpTransaction returns an error if reduce_output is out of range. This code just ignores it. Probably should be consistent.

Copy link
Member

Choose a reason for hiding this comment

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

"change" is really over-loaded here, please call it something else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@luke-jr Agreed - now consistent.

@instagibbs Renamed to reduce_output_vout.

Copy link
Member

Choose a reason for hiding this comment

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

Couldn't this result in the reduce_output getting increased? That could be a serious problem in some cases...

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'm not sure I follow. In which case would reduce_output increase?

Currently, bumpfee cannot be used to bump a single output transaction. This should be possible, as single output transactions are special in that the exact amount doesn't usually matter (the user is emptying a wallet or using coin control to move UTXOs).
@DrahtBot
Copy link
Contributor

Needs rebase

@kallewoof
Copy link
Contributor Author

Rebase is becoming overwhelming on this. Closing until further notice (may rewrite the code).

@kallewoof kallewoof closed this Jun 19, 2019
@kallewoof kallewoof deleted the better-bumpfee branch October 17, 2019 08:56
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 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.