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

Reversible vtxo in async payment #311

Merged
merged 30 commits into from
Sep 19, 2024

Conversation

louisinger
Copy link
Collaborator

@louisinger louisinger commented Sep 15, 2024

This PR adds the necessary abstraction to process different types of VTXOs. It allows adding the ReversibleVtxoScript type used as output of async payments.

Vtxo script type

  • A vtxo script is defined as a taproot contract with at least 1 forfeit closure (User && ASP) and 1 exit closure (A after t). It may contain others closures implementing specific use cases.
  • common.VtxoScript abstracts the taproot complexity of vtxo script.
  • a vtxo script is compiled, transferred and parsed using descriptor string.
  • the default vtxo script is tr(_,{ and(pk(USER), pk(ASP)), and(older(T), pk(USER)) })
  • the reversible vtxo script is tr(_,{ { and(pk(SENDER), pk(ASP)), and(older(T), pk(SENDER)) }, { and(pk(RECEIVER), pk(ASP) } })
  • while spending a VTXO, the spender must provide the associated descriptor and the signer public key (in order to signal to the ASP the forfeit leaf to use)

TL;DR

  • [common] add VtxoScript interface
  • [tx-builder] use VtxoScript to craft vtxo tree transactions
  • [api-spec] add descriptor instead of pubkey while registering inputs
  • [api-spec] add signingPubKey when spending a VTXO
  • [api-spec] specify descriptor instead of offchain address while registering outputs
  • [db] replace Vtxo.Pubkey by Vtxo.Descriptor

PS: This PR does not add the necessary change to support the "Reverse" UX in the SDK even if it's technically possible today for the sender to spend (via reverse forfeit leaf) an async payment VTXO. It may need extra work to keep track of the reversible VTXOs and coin-select them.

@altafan @tiero @sekulicd @bordalix please review

@tiero
Copy link
Member

tiero commented Sep 17, 2024

May be worth to lay down the ground work of key path spending for cooperative cases? We may not need to migrate right now, but at least figuring out the abstraction of needs some more work in the future, better now

@altafan altafan merged commit 10ef0db into ark-network:master Sep 19, 2024
6 checks passed
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.

4 participants