Skip to content

Adding the Swap feature

Palmer Sébastien requested to merge palmer@functori@swap-feature into main

This MR enables the Ledger swap function:

  • Add ENABLE_SWAP tag
  • Provide the 4 required functions:
    • The swap_handle_check_address function which checks an address.
    • The swap_handle_get_printable_amount function, which gives the print format for an amount.
    • The swap_copy_transaction_parameters function, which backs up transaction parameters.
    • The swap_finalize_exchange_sign_transaction function which finalizes the exchange.
  • During a swap, check that the transaction matches the backed-up parameters.

I made some choices in the implementation:

  • In check_address: the derivation_type is set to ED25519 (since no parameter defines it).
  • In check_address/copy_transaction_parameters: the extra_id must be non-null and empty.
  • In the get_printable_amount function: the ticker and the number of decimals given by the caller are those used for print. Should we instead force the display with tz and 6 decimals?
  • In copy_transaction_parameters/check_validity: the ticker and the number of decimals are not taken into account, the amount/fee values are just compared without decimals.
Edited by Palmer Sébastien

Merge request reports