Skip to content

Conversation

@random-zebra
Copy link

@random-zebra random-zebra commented Nov 13, 2020

Refactor SaplingOperation, abstracting the separation between shielded and transparent outputs inside SendManyRecipient.
Instead of using strings for the internal representation, save the recipients as either CTxOut (for transparent outputs) or a tuple comprising SaplingAddress, Amount and Memo (for sapling outputs).

This has the following pros:

  • Cleaner: No extra "dummy" variables (such as the memo field for transparent outputs). Plus, as the separation between shielded/transparent recipients is implemented only in the TransactionBuilder, SaplingOperation effectively has an higher level of abstraction.
  • Faster: removes the need for extra encoding-decoding operations to go back and forth between strings and scripts.
  • More flexible: since a CTxOut can be any kind of transaction output, we can easily integrate other use-cases.
    For example, in this PR we add support for multisig, P2CS and op_return outputs.

@random-zebra
Copy link
Author

Rebased.

furszy
furszy previously approved these changes Nov 15, 2020
Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

Overall looking great, ACK 67130a65 .

The only minor thing that would add in every SendManyRecipient constructor is the nullopt member initialization for the member that is not used. Example, if it's being feed by a shielded addr, set the transparent optional to nullopt and vice versa.

Save them as either CTxOut (transparent outputs) or a tuple with sapling
address, amount and memo (shielded outputs), instead of strings.

This saves a redundant Encoding/Decoding operation while offering more
flexibility (allowing for all possible kinds of transparent outputs).
@random-zebra
Copy link
Author

Rebased on master and added initializer lists.

Copy link

@furszy furszy left a comment

Choose a reason for hiding this comment

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

utACK cf9d4df after rebase and merging..

@furszy furszy merged commit 226aaaa into PIVX-Project:master Nov 16, 2020
Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

post-merge ACK cf9d4df

furszy added a commit that referenced this pull request Nov 18, 2020
467b0d8 [Tests] Check delegations with sapling transactions (random-zebra)
d412525 [RPC] Add fUseShielded parameter to delegatestake/rawdelegatestake (random-zebra)
847d278 [Trivial] Missing newline in delegatestake (random-zebra)
7440709 [Validation] Don't reject sapling txes with P2CS outputs (random-zebra)

Pull request description:

  Enable pay-to-cold-staking outputs in shielded transactions.
  Add the option in `delegatestake`/`rawdelegatestake` to spend shielded funds directly to P2CS (without having to unshield them first).

  Add functional test.

  Based on top of
  - [x] #1964
  - [x] #1967
  - [x] #1969

  Starts with `[Validation] Don't reject sapling txes with P2CS outputs` (461d4ea69ea21ea639ae639d4248b4ef28312429)

ACKs for top commit:
  furszy:
    Looking good, ACK 467b0d8
  Fuzzbawls:
    ACK 467b0d8

Tree-SHA512: 88752fe1550def605b90cc894d0666f5c37dd8f075566e976c8fbfaa6e088ee0c1bb028e1885411b739781fda6ebac12a5c99fc19a06f453e594441ee1e1b599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants