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

Privacy improvements for direct_send() #492

Merged
merged 1 commit into from
Jan 12, 2020
Merged

Privacy improvements for direct_send() #492

merged 1 commit into from
Jan 12, 2020

Conversation

kristapsk
Copy link
Member

  • Shuffle order of tx inputs and outputs
  • Set locktime for best anonset (Core, Electrum)

Also make P2EP use the same locktime code instead of copy/paste. Note that Core / Electrum does not always set current block height as locktime, at random cases it sets some older value. This code does the same.

@chris-belcher
Copy link
Contributor

Concept ACK.

Further reading: JoinMarket-Org/joinmarket#755

Do we also need to set the nSequence numbers? See undeath's comment in that thread.

@@ -605,11 +605,7 @@ def on_tx_received(self, nick, txhex):
"value": new_change_amount})
new_ins = [x[1] for x in utxo.values()]
new_ins.extend(my_utxos.keys())
# set locktime for best anonset (Core, Electrum) - most recent block.
# this call should never fail so no catch here.
currentblock = jm_single().bc_interface.rpc(
Copy link
Member

Choose a reason for hiding this comment

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

As @chris-belcher pointed out in another recent PR thread, it's a failure of the abstraction to be referring to an rpc method here, it should be the business of the blockchaininterface (not even the walletservice, really - although currently there are rpc calls there, we should change that albeit it's not urgent) that rpc is being used, client shouldn't know about it. Could you maybe create a get_block_height() or similar function in walletservice which the get_default_locktime() uses, and is also called here?

@AdamISZ
Copy link
Member

AdamISZ commented Jan 11, 2020

* Shuffle order of tx inputs and outputs

* Set locktime for best anonset (Core, Electrum)

Also make P2EP use the same locktime code instead of copy/paste. Note that Core / Electrum does not always set current block height as locktime, at random cases it sets some older value. This code does the same.

Just for other readers, want to be clear:
"shuffle ins and outs" - this wasn't yet done for direct send (no coinjoin) transactions (fine for inputs, they have no order - but outputs should definitely have it!), it was of course done for Joinmarket coinjoins and PayJoins.

And that re: the locktime, our current code used latest block (except direct send again), but we should do better in matching the pattern to Core and Electrum as explained above.

Thanks for this PR and the careful code reading :)

concept ACK though see above architectural quibble.

@@ -92,6 +93,17 @@ def estimate_tx_fee(ins, outs, txtype='p2pkh'):
raise NotImplementedError("Txtype: " + txtype + " not implemented.")


def get_default_locktime():
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the function called get_default_locktime() ? What's default about it. The name doesn't make much sense IMO. Maybe get_anti_fee_snipe_locktime() or compute_tx_locktime() or get_tx_locktime().

* Shuffle order of tx inputs and outputs
* Set locktime for best anonset (Core, Electrum)
@kristapsk
Copy link
Member Author

Added get_current_block_height() method to blockchain interface and renamed locktime returning function to compute_tx_locktime().

@chris-belcher
Copy link
Contributor

utACK

@AdamISZ
Copy link
Member

AdamISZ commented Jan 12, 2020

W.r.t. compute_tx_locktime() and its location:

It's interesting to note that this has something in common with another function in the same file, wallet.py: they both are the only reference to jm_single().bc_interface in that file.

This is kind of what i was trying to avoid with the WalletService architecture.
I'm not going to get into some rant about how I think the code should be organized, I'm sure you already know the general idea behind #359 and so on. But I guess just to note: both those functions (compute_tx_locktime() and estimate_tx_fee()) don't really have a dependency on the wallet. I think at some point we should just put them in the actual WalletService object.

But since I don't think that's critical at all, utACK to c23808f

kristapsk added a commit that referenced this pull request Jan 12, 2020
c23808f Privacy improvements for direct_send() (Kristaps Kaupe)

Pull request description:

  * Shuffle order of tx inputs and outputs
  * Set locktime for best anonset (Core, Electrum)

  Also make P2EP use the same locktime code instead of copy/paste. Note that Core / Electrum does not always set current block height as locktime, at random cases it sets some older value. This code does the same.

ACKs for top commit:
  AdamISZ:
    But since I don't think that's critical at all, utACK to c23808f

Tree-SHA512: d0fb838b4fdee8be3ce8c1f38f110655697bf77c361a00b299128e7af5da8dc82aca7b7302b610b25a9037493a97496263a83d504d04cfa88070bc0032781885
@kristapsk kristapsk merged commit c23808f into JoinMarket-Org:master Jan 12, 2020
@kristapsk kristapsk deleted the direct_send-locktime branch January 12, 2020 18:51
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.

3 participants