Skip to content

Conversation

@notmandatory
Copy link
Member

@notmandatory notmandatory commented Aug 18, 2025

Description

Notes to the reviewers

The original purpose of this was to simplify the API as much as possible by only returning required data from commands instead of the entire APDU message which contains fields only needed for validation or to update the nonce. Along the way I realized the generics can be removed which makes the FFI bindings easier to do and generally simplifies the code. I also cleaned up some other warnings and dependencies.

I added lib sign and sign_psbt commands for SatsCard and refactored errors for all commands to be more tailored to what could actually go wrong. I also added "sign <psbt>" and "dump <slot>" commands to the cli for SatsCard, and exposed all lib commands and errors in the FFI bindings.

Changelog notice

  • Reduced data returned from most commands to just what is needed
  • Fixed warnings
  • Add lib sign and sign_psbt functions for SatsCard
  • Refactored lib errors to be more tailored to the commands
  • Add cli "sign <psbt>" and "dump <slot>" commands for SatsCard
  • Expanded FFI bindings to all available lib commands and errors
  • Added top level Justfile

Checklists

All Submissions:

  • I've signed all my commits
  • I followed the contribution guidelines
  • I ran cargo fmt and cargo clippy before committing

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

Bugfixes:

  • This pull request breaks the existing API
  • I've added tests to reproduce the issue which are now passing
  • I'm linking the issue being fixed by this PR

@notmandatory notmandatory self-assigned this Aug 18, 2025
@notmandatory notmandatory force-pushed the api_cleanup branch 2 times, most recently from b98e1f4 to 1361a7c Compare August 18, 2025 02:46
@notmandatory
Copy link
Member Author

@reez I'm going to need your help figuring out how to test the FFI bindings with Swift to exercise the new CkTransport trait.

Reduce returned command data to just what is needed
instead of entire response message.
@reez
Copy link
Contributor

reez commented Aug 18, 2025

@reez I'm going to need your help figuring out how to test the FFI bindings with Swift to exercise the new CkTransport trait.

Cool, let's take a look at this together tomorrow!

@reez
Copy link
Contributor

reez commented Aug 19, 2025

Tested local bindings and made version + address call successfully ✅

@notmandatory
Copy link
Member Author

notmandatory commented Aug 20, 2025

I also had some success today and got my Swift test working with a custom CkTransport that talks to a locally running card emulator. So now I should be able to move on to adding the rest of the APIs to the ffi bindings.

@notmandatory
Copy link
Member Author

Got SATSCARD sign and sign_psbt functions working with emulator unit test and with a real card on mainnet. I used bdk-cli to construct my PSBT, signed it with the rust-cktap cli and my SATSCARD, then finalized and broadcast it with the bdk-cli.

cc: @praveenperera

@notmandatory notmandatory added the enhancement New feature or request label Aug 22, 2025
@notmandatory notmandatory marked this pull request as ready for review August 22, 2025 04:24
@notmandatory notmandatory force-pushed the api_cleanup branch 2 times, most recently from 3054c4a to dedd262 Compare August 27, 2025 04:14
Also make all apdu types crate(pub) instead of pub.
Fixed doc error with ref URLs.
@notmandatory
Copy link
Member Author

notmandatory commented Aug 30, 2025

I should be all done with refactoring and exposing all implemented card commands via ffi. The nfc and xpub commands still need to be implemented but can do in follow-up PRs.

@notmandatory notmandatory force-pushed the api_cleanup branch 2 times, most recently from 0ad90c4 to c0f1c68 Compare August 30, 2025 18:29
Also update README completed commands.
@notmandatory notmandatory merged commit 4694844 into master Sep 1, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants