Skip to content

Add enhanced trustless swap itest (anyonecanspend scriptkey) #857

Open
@GeorgeTsagk

Description

@GeorgeTsagk

Description

In #804 we added an itest that follows the trustless swap flow originally described in #577. That version of the trustless swap ran into some limitations and we had to add a design restriction -- alice can only swap a "whole coin", i.e there can not be any asset change going back to the creator of the swap.

This is because due to the non-interactive nature of the swap, the control of the asset root needs to belong to the swap receiver. By doing so, the swap receiver would be able to burn the creator's asset change. If the swap creator never pays any change back to themselves there's no risk, hence the swap flow makes sense for both parties.

Enhanced Version

There is a different approach to this, which would not require the swap receiver to be in control of the asset root. The swap creator can pay the amount they wish to swap to an anyone-can-spend script key on the asset level, and let the swap receiver anchor it to an outpoint that they control. This way, the swap receiver will effectively be in full control of the swapped amount.

On the bitcoin level, the swap creator would again use SIGHASH_SINGLE | ANYONECANPAY to allow for the swap receiver to plug-in their own btc (to satisfy the creator) and also create extra outputs for their own anchor and btc change.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions