Skip to content

Conversation

@instagibbs
Copy link
Member

@instagibbs instagibbs commented Mar 16, 2018

Unless there is something important I'm missing, we're just possible leaking information by preserving whatever ordering json object ordering is giving us (no guarantees at all).

This is unneeded for sendtoaddress since there is only 1 or 2 outputs, and the change output is shuffled in.

This will not effect *raw behavior by design, since users generally want full control using those apis. Further PRs could add optional args to over-ride that behavior.

Alternative ideas would be to sort the outputs by some deterministic ordering. (this would require more refactoring since change outputs are created and handled by caller)

related: #12699

@instagibbs instagibbs changed the title shuffle sendmany recipients ordering, since caller cannot control [wallet] shuffle sendmany recipients ordering, since caller cannot control Mar 16, 2018
@ryanofsky
Copy link
Contributor

since caller cannot control

It's not really true that the caller can't control this. But maybe we don't want to allow them to. Whether the caller can control the order just depends on how they are generating their request, and what JSON library they are using if any. The python json library and our c++ UniValue library do allow control over ordering.

@instagibbs
Copy link
Member Author

@ryanofsky ok, I was operating under the same assumption as #11872

I believe the arguments to change the behavior is still strong.

Copy link
Contributor

@donaloconnor donaloconnor left a comment

Choose a reason for hiding this comment

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

utACK fdc2e31

@jonasschnelli
Copy link
Contributor

IMO the sendmany API has no order (per JSON specs) due to the use of an associated array (object) ( {\"address\":amount,...}).

Maybe we should mention this in the release notes?

utACK fdc2e316ddea8454cc329ff8f0694c0a1740f508

@maflcko
Copy link
Member

maflcko commented Mar 18, 2018

Yes this definitely needs mention in the release notes, since the caller can control the order as explained by @ryanofsky

@maflcko
Copy link
Member

maflcko commented Mar 18, 2018

Also, I think for API clarity we should accept a list that allows duplicates regardless of json implementation. Similar to #11872

@promag
Copy link
Contributor

promag commented Mar 20, 2018

But maybe we don't want to allow them to

@ryanofsky why not? The same could be said in #11872?

@instagibbs
Copy link
Member Author

@promag raw transaction APIs are a completely different beast, where caller expects more control, and can do their own shuffling if required

@instagibbs
Copy link
Member Author

I will add release notes.

@promag
Copy link
Contributor

promag commented Mar 21, 2018

@instagibbs got it. Agree with @MarcoFalke though in doing something similar to #11872 in a different PR.

the caller can control the order

It can be a pain in some cases, so I don't think we should focus on that before doing the same as #11872.

@sipa
Copy link
Member

sipa commented Mar 21, 2018

utACK fdc2e316ddea8454cc329ff8f0694c0a1740f508. This merits a release notes update, though.

@sipa
Copy link
Member

sipa commented Mar 21, 2018

@instagibbs Have a look at #12742; that should permit a faster implementation that doesn't need a call to OpenSSL for every output in the list.

Copy link
Member

Choose a reason for hiding this comment

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

Please rebase on top of #12742 and use std::shuffle from cpp11 to avoid future code churn.

@instagibbs
Copy link
Member Author

rebased onto #12742 and added release note.

@instagibbs instagibbs changed the title [wallet] shuffle sendmany recipients ordering, since caller cannot control [wallet] shuffle sendmany recipients ordering Mar 21, 2018
@sipa
Copy link
Member

sipa commented Mar 22, 2018

utACK 76cc7f9bfe530cce24800cd317e0c36b5610a1cd

@maflcko
Copy link
Member

maflcko commented Mar 22, 2018

utACK 76cc7f9

@promag
Copy link
Contributor

promag commented Mar 22, 2018

utACK 76cc7f9.

@instagibbs
Copy link
Member Author

had to rebase due to release notes conflict :(

@maflcko
Copy link
Member

maflcko commented Mar 23, 2018

re-utACK 6acb02d

@promag
Copy link
Contributor

promag commented Mar 23, 2018

utACK 6acb02d.

@maflcko maflcko merged commit 6acb02d into bitcoin:master Mar 23, 2018
maflcko pushed a commit that referenced this pull request Mar 23, 2018
6acb02d add release note for sendmany output shuffling (Gregory Sanders)
cf6ef3c shuffle sendmany recipients ordering to shuffle tx outputs (Gregory Sanders)

Pull request description:

  Unless there is something important I'm missing, we're just possible leaking information by preserving whatever ordering json object ordering is giving us (no guarantees at all).

  This is unneeded for `sendtoaddress` since there is only 1 or 2 outputs, and the change output is shuffled in.

  This will not effect `*raw` behavior by design, since users generally want full control using those apis. Further PRs could add optional args to over-ride that behavior.

  Alternative ideas would be to sort the outputs by some deterministic ordering. (this would require more refactoring since change outputs are created and handled by caller)

  related: #12699

Tree-SHA512: afdd990dde6a4a9e7eef7bb2e3342a46d11900d7fe6e6e4eb0cc6b5deed89df989fa7931a4bdcbf49b7c2d7a13c90169af3a166466e5760948bacabe3490f572
Fabcien pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Aug 30, 2019
Summary:
6acb02d add release note for sendmany output shuffling (Gregory Sanders)
cf6ef3c shuffle sendmany recipients ordering to shuffle tx outputs (Gregory Sanders)

Pull request description:

  Unless there is something important I'm missing, we're just possible leaking information by preserving whatever ordering json object ordering is giving us (no guarantees at all).

  This is unneeded for `sendtoaddress` since there is only 1 or 2 outputs, and the change output is shuffled in.

  This will not effect `*raw` behavior by design, since users generally want full control using those apis. Further PRs could add optional args to over-ride that behavior.

  Alternative ideas would be to sort the outputs by some deterministic ordering. (this would require more refactoring since change outputs are created and handled by caller)

  related: bitcoin/bitcoin#12699

Tree-SHA512: afdd990dde6a4a9e7eef7bb2e3342a46d11900d7fe6e6e4eb0cc6b5deed89df989fa7931a4bdcbf49b7c2d7a13c90169af3a166466e5760948bacabe3490f572

Backport of Core PR12709
bitcoin/bitcoin#12709

Test Plan:
  make check
  test_runner.py

Reviewers: deadalnix, Fabien, jasonbcox, O1 Bitcoin ABC, #bitcoin_abc

Reviewed By: deadalnix, O1 Bitcoin ABC, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D3897
@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants