Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Clone transaction before committing to wallet #21

Closed

Conversation

sqrrm
Copy link
Member

@sqrrm sqrrm commented Jan 6, 2019

Created a new PR after the discussions in #18

@sqrrm
Copy link
Member Author

sqrrm commented Jan 6, 2019

I think we should get this in for the release after next, so no rush but good to run in testnet for a bit.

// Clone transaction to avoid multiple wallets pointing to the same transaction. This can happen when
// two wallets depend on the same transaction.
tx = tx.getParams().getDefaultSerializer().makeTransaction(tx.bitcoinSerialize());

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this couple of lines can be deleted. tx already cloned bellow

Copy link
Member Author

Choose a reason for hiding this comment

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

It stores it in riskDropped and returns, that's why it needs to be cloned here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah, you are right.

@oscarguindzberg
Copy link
Collaborator

utACK

@ManfredKarrer
Copy link
Member

@sqrrm
I discussed the issue with @oscarguindzberg
I think it is too risky to clone every tx at a low level. We are not clear what can be the consequences as the pointers to the connected outputs (from the inputs) are not not cloned and might cause issues at some use cases.
Another point is that conceptually a single tx shared between wallets is probably the correct design and the follow up problems should rather be fixed instead of copying txs. This all requires quite a bit of work and analysis and as long we don't have a strong use case where we run into problems I prefer to postpone that to a later point of time.
So I would suggest to close the PR.

@sqrrm
Copy link
Member Author

sqrrm commented Jan 7, 2019

@ManfredKarrer I think it's quite clear that having the same tx instance in multiple wallets in bitcoinj is not how it's intended. When transactions are received from blocks they're cloned, see AbstractBlockChain:882. I think the reason they're not cloned when received from the broadcast callback is an oversight from the wallet developer.

The connected outputs are only set after a tx enters the wallet from what I understand. This also fits with how the external txs are cloned when added to multiple wallets.

I can still understand your hesitation to merge this too soon, but I think the conclusions are wrong regarding the risks and how the bitcoinj wallet works. Since we're already doing the cloning when publishing from the BSQ wallet it's not extremely urgent to fix this, but as mentioned before, I think it's worth fixing before going live on mainnet.

@ManfredKarrer
Copy link
Member

Yes, lets keep it for later. Just don't want to open up risk when I don't see the use case which causes the problem.

@sqrrm sqrrm changed the title Clone transaction before committing to wallet [WIP] Clone transaction before committing to wallet Jan 10, 2019
@oscarguindzberg
Copy link
Collaborator

Related bitcoinj#1553

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants