bitcoinj-cash / bitcoinj

A library for working with Bitcoin
http://bitcoinj.cash
Apache License 2.0
64 stars 35 forks source link

Empty wallet using multiple outputs #76

Closed rafa-js closed 6 years ago

rafa-js commented 6 years ago

I have noticed you can't use multiple outputs in a SendRequest using the emptyWallet option. I understand this makes sense when this outputs have a value but, what happens if the output is an OP_RETURN? Why should't be correct create an emptyWallet request including an OP_RETURN?

This is line I'm referring to: https://github.com/bitcoinj-cash/bitcoinj/blob/cash-0.14/core/src/main/java/org/bitcoinj/wallet/Wallet.java#L3986

Not sure if this is a bug or I'm missing any consideration.

HashEngineering commented 6 years ago

The original author's must not have considered what you were doing. Perhaps they where thinking that the other output could be a change output, but they didn't want a change output on an empty wallet request.

I don't think this is a bug, but it is by design for a simple transaction type where all funds in all addresses in the wallet are sent to a single output.

Your use case will require a change to the existing code.

rafa-js commented 6 years ago

Yeah, I guess what they meant with this code, but even in agreement with their intentions I think the implementation is not very accurate.

Will change that to make it work in my use case. Thanks @HashEngineering for answering.