This commit is contained in:
jonesmarvin8 2026-05-09 16:08:28 -04:00
parent d98f13adde
commit ede66bb37e
5 changed files with 691 additions and 245 deletions

View File

@ -49,14 +49,13 @@ source venv/bin/activate
### Keycard
| Command | Description |
|------------------------|-------------------------------------------------------------------------|
| `wallet keycard available` | Checks whether Keycard is accessible |
| `wallet keycard load` | Loads a new mnemonic phrase onto Keycard |
| `wallet keycard get-private-keys` | Retrieves private account keys (nsk, vsk) given a ChainIndex |
| `wallet help` | Help |
| Command | Key-path options | Description |
|-----------------------------------|------------------|--------------------------------------------------------------------------|
| `wallet keycard available` | — | Checks whether a Keycard reader and card are accessible |
| `wallet keycard load` | — | Loads a mnemonic phrase onto the Keycard |
| `wallet keycard get-private-keys` | `--key-path` | Retrieves private account keys (nsk, vsk) for the given BIP32 path |
### 1. Check keycard availability
1. Check keycard availability
```bash
wallet keycard available
@ -64,154 +63,348 @@ wallet keycard available
✅ Keycard is available.
```
### 2. Load a new mnemonic phrase
2. Load a mnemonic phrase
```bash
wallet keycard load --mnemonic "fashion degree mountain wool question damp current pond grow dolphin chronic then"
# Output:
Keycard PIN: # Enter Keycard pin
Keycard PIN:
✅ Keycard is now connected to wallet.
```
### 3. Ger private key
3. Get private keys for a path
```bash
wallet keycard get-private-keys --key-path "m/44'/60'/0'/0/0"
# Output:
Keycard PIN: # Enter Keycard pin
Keycard PIN:
nsk: 55e505bf925e536c843a12ebc08c41ca5f4761eeeb7fa33725f0b44e6f1ac2e4
vsk: 30f798893977a7b7263d1f77abf58e11e014428c92030d6a02fe363cceb41ffa
```
### Pinata (testnet)
| Command | Description |
|------------------------|---------------------------------------------------------------------|
| `wallet pinata claim` | Accepts ChainIndex (key path) for public account to send pinata reward to|
- See example in Authenicated-transfers examples.
| Command | Key-path options | Description |
|-----------------------|-------------------------------|--------------------------------------------------------------------------|
| `wallet pinata claim` | `--key-path` | Claims a testnet pinata reward to a public or private recipient account |
### Authenticated-transfer program
Note: The recipient account must be initialized with `wallet auth-transfer init` before claiming.
| Command | Description |
|------------------------|---------------------------------------------------------------------|
| `wallet auth-transfer init` | Accepts ChainIndex (key path) for public account to initialize|
| `wallet auth-transfer send` | Accepts ChainIndices (key paths) for `from` and `to` |
1. Initialize public account.
```bash
wallet auth-transfer init --key-path "m/44'/60'/0'/0/0"
#Output
Keycard PIN: # Enter Keycard pin
Transaction hash is 49c16940493e1618c393645c1211b5c793d405838221c29ac6562a8a4b11c5a7
Transaction data is Public(PublicTransaction { message: Message { program_id: "adbf67b01ded1e29c7a0b7b1b580e6ad4166a8fd52b57bf629fe78d4c779a48a", account_ids: [Fh8d1HsqEUDzwg1vc1E9123nRpEGHJwwdqtiWu73JHPP], nonces: [Nonce(0)], instruction_data: [0, 0, 0, 0] }, witness_set: WitnessSet { signatures_and_public_keys: [(9b43433cce6f0c5c268e408c0e300b8767c11f462a2fbea50b22b3f52ddeea86b5c3e959c1d3625603e4d22b8ccff62caa7819e28761cec9bbfb32b87a9e0c81, 0a5873812f910609da22d8aef918632677f3208faa3cec2b692f3e4c37ffd11d)] } })
Stored persistent accounts at /home/mara/.nssa/wallet/storage.json
```
2. Fund initialized public account with Pinata reward.
1. Claim to a Keycard public account
```bash
wallet pinata claim --key-path "m/44'/60'/0'/0/0"
#Output:
Keycard PIN: # Enter Keycard pin
# Output:
Keycard PIN:
Computing solution for pinata...
Found solution 989106 in 33.739525ms
Transaction hash is fd320c01f5469e62d2486afa1d9d5be39afcca0cd01d1575905b7acd95cf6397
Transaction data is Public(PublicTransaction { message: Message { program_id: "d68109238654ce4c7af77ba2cdeb3f3d8eb3ea1fb563b9d5b15c0f081c3d6f40", account_ids: [EfQhKQAkX2FJiwNii2WFQsGndjvF1Mzd7RuVe7QdPLw7, Fh8d1HsqEUDzwg1vc1E9123nRpEGHJwwdqtiWu73JHPP], nonces: [], instruction_data: [989106, 0, 0, 0] }, witness_set: WitnessSet { signatures_and_public_keys: [] } })
```
3. Initialize new public account and send funds.
2. Claim to a local wallet account by label
```bash
# Initialize new Keycard public account.
wallet auth-transfer init --key-path "m/44'/60'/0'/0/1"
wallet pinata claim --to-label my-account
# Output:
Keycard PIN: # Enter Keycard pin
Transaction hash is a801bd61c0acc04917fb61e8e27673591df368ab0542c68a5cb1cf2272744d8e
Transaction data is Public(PublicTransaction { message: Message { program_id: "adbf67b01ded1e29c7a0b7b1b580e6ad4166a8fd52b57bf629fe78d4c779a48a", account_ids: [7ZMZuc3FgzHj3pSggGP1kbeZRCdwD8L4P8Wg9N2qsYcB], nonces: [Nonce(0)], instruction_data: [0, 0, 0, 0] }, witness_set: WitnessSet { signatures_and_public_keys: [(4470c76742e3a965fd07c5d5510a25a8e9b553f922df40ec5c4585e2b765e4c15056ee7485440b49762f92654bb7f4bba0565cbc7e70154ae475c990052cb830, 1c53c6a6c5e552fd739b3812f04381c0e502278fe851efea491cfd2f560cd25d)] } })
Stored persistent accounts at /home/mara/.nssa/wallet/storage.json
Transaction hash is 2c8a4f1e903d5b76e80214c5b82e1d46a105e28930ad71bcce48f2d07b49a16f
```
# Send native tokens from one account to the other.
wallet auth-transfer send --amount 40 \
### Authenticated-transfer program
| Command | Key-path options | Description |
|-----------------------------|--------------------------------------|------------------------------------------------------------------------------------|
| `wallet auth-transfer init` | `--key-path` | Registers a public or private account with the auth-transfer program |
| `wallet auth-transfer send` | `--from-key-path`, `--to-key-path` | Sends native tokens; either or both endpoints can be Keycard public accounts |
For `send`, `--from-key-path` and `--to-key-path` can be used together (both Keycard) or individually (one Keycard, one local/label). Shielded sends to foreign private accounts use `--to-npk`/`--to-vpk` instead of `--to-key-path`.
1. Initialize a Keycard public account
```bash
wallet auth-transfer init --key-path "m/44'/60'/0'/0/0"
# Output:
Keycard PIN:
Transaction hash is 49c16940493e1618c393645c1211b5c793d405838221c29ac6562a8a4b11c5a7
```
2. Send native tokens between two Keycard accounts
```bash
wallet auth-transfer send \
--from-key-path "m/44'/60'/0'/0/0" \
--to-key-path "m/44'/60'/0'/0/1"
--to-key-path "m/44'/60'/0'/0/1" \
--amount 40
# Output:
Keycard PIN: # Enter Keycard pin
Keycard PIN:
Transaction hash is 1a9764ab20763dcc1ffb51c6e9badd5a6316a773759032ca48e0eee59caaf488
Transaction data is Public(PublicTransaction { message: Message { program_id: "adbf67b01ded1e29c7a0b7b1b580e6ad4166a8fd52b57bf629fe78d4c779a48a", account_ids: [Fh8d1HsqEUDzwg1vc1E9123nRpEGHJwwdqtiWu73JHPP, 7ZMZuc3FgzHj3pSggGP1kbeZRCdwD8L4P8Wg9N2qsYcB], nonces: [Nonce(1), Nonce(1)], instruction_data: [40, 0, 0, 0] }, witness_set: WitnessSet { signatures_and_public_keys: [(073fc99121c9d95de120b15057fdd922de2bb059db8382674f600cd2047aa97d1d2cad09becd8e05014a3704916f41e29eedf002649bffe7864f431a75d5f6a2, 0a5873812f910609da22d8aef918632677f3208faa3cec2b692f3e4c37ffd11d), (e6feaafd2de792be0f7f94312c3a97285e7b1f806388a0c10f7a5123a3d0389363fe35d0d56f1af21a0ead999a015d89479c004cc4dd33078efb17611b50b590, 1c53c6a6c5e552fd739b3812f04381c0e502278fe851efea491cfd2f560cd25d)] } })
```
4. Shielded transfer:
3. Send native tokens from Keycard to a local wallet account
```bash
wallet auth-transfer send --amount 2 \
# Note: non-keycard account ID below — replace with actual account ID or use --to-label
wallet auth-transfer send \
--from-key-path "m/44'/60'/0'/0/0" \
--to "Public/9bKmZ4n7PqVRxEtY3dWsQjA2cHrFT5LpDoGXM8wJuNv6" \
--amount 20
# Output:
Keycard PIN:
Transaction hash is 3e7b2a91cf804d56fe19084b3c8b25d07e8f243829bc50addf6e2c78b4b09d34
```
4. Shielded send from Keycard to a foreign private account
```bash
wallet auth-transfer send \
--from-key-path "m/44'/60'/0'/0/0" \
--to-npk "55204e2934045b044f06d8222b454d46b54788f33c7dec4f6733d441703bb0e6" \
--to-vpk "02a8626b0c0ad9383c5678dad48c3969b4174fb377cdb03a6259648032c774cec8"
--to-vpk "02a8626b0c0ad9383c5678dad48c3969b4174fb377cdb03a6259648032c774cec8" \
--amount 2
# Output:
Keycard PIN: # Enter Keycard pin
Keycard PIN:
Transaction hash is 8ad4b2dc5ab2c08bb6eefca6ec9b18151fa4452cd7e2a636c2fb158ecb46aef6
Stored persistent accounts at /home/mara/.nssa/wallet/storage.json
Shielded auth-transfer sent
```
### Account
| Command | Description |
|------------------------|---------------------------------------------------------------------|
| `wallet account get` | Get public account data given its ChainIndex (key path) |
| Command | Key-path options | Description |
|------------------------------|------------------|---------------------------------------------------------------------------|
| `wallet account get` | `--key-path` | Retrieves on-chain account data; accepts a Keycard path, label, or ID |
| `wallet account id` | `--key-path` | Prints the raw account ID for a Keycard path (useful for shell scripting) |
1. Get account state by Keycard path
```bash
wallet account get --key-path "m/44'/60'/0'/0/0"
# Output:
Keycard PIN: # Enter Keycard pin
Keycard PIN:
Account owned by authenticated transfer program
{"balance":108,"program_owner":"ChEp4BuCdGzJDHWoG1PTZLfZBbPxhYzstVMdakxym6bb","data":"","nonce":3}
```
### Token program
| Command | Description |
|------------------------|---------------------------------------------------------------------|
| `wallet token new` | ChainIndices (key paths) provided for definition and supply |
| `wallet token init` | ChaindIndex (key path) to initialize Keycard public account |
| `wallet token send` | ChainIndices (key paths) for `from` and `to` public accounts |
| `wallet token burn` | ChainIndex (key path) for holding account |
| `wallet token mint` | ChainIndices (key paths) for definition and holding public accounts |
These commands work as expected, but uses `key-path` features to use a public account via Keycard.
1. Initialize new Token
2. Print raw account ID for shell scripting
```bash
wallet token new \
--definition-key-path "m/44'/60'/0'/1/0" \
--supply-key-path "m/44'/60'/0'/1/1" \
--total-supply 100000 \
--name SNT
LEZ_DEF=$(wallet account id --key-path "m/44'/60'/0'/0/0")
# Output:
Keycard PIN:
Transaction hash is 2f0ddd9ad46e1c8cde8dac4eb69ebb5d8fdf167647e421aa79900adaaa9b34d0
# Output:
Keycard PIN:
# Prints: Fh8d1HsqEUDzwg1vc1E9123nRpEGHJwwdqtiWu73JHPP
```
2. Initialize new token holding
### Token program
| Command | Key-path options | Description |
|------------------------|---------------------------------------------------------------------------|------------------------------------------------------------------------|
| `wallet token new` | `--definition-key-path`, `--supply-key-path` | Creates a new token; Keycard signs for definition and supply accounts |
| `wallet token init` | `--holder-key-path` | Initializes a token holding for a Keycard public account |
| `wallet token send` | `--from-key-path`, `--to-key-path` | Transfers tokens between accounts; either endpoint can be Keycard |
| `wallet token burn` | `--holder-key-path` | Burns tokens from a Keycard holding account |
| `wallet token mint` | `--definition-key-path`, `--holder-key-path` | Mints tokens; Keycard signs for definition and/or holding account |
These commands work as expected, but use `--key-path` options to sign with a Keycard public account instead of a local wallet account.
1. Create new token
```bash
wallet token new \
--definition-key-path "m/44'/60'/0'/0/0" \
--supply-key-path "m/44'/60'/0'/0/1" \
--name SNT \
--total-supply 100000
# Output:
Keycard PIN:
Transaction hash is 2f0ddd9ad46e1c8cde8dac4eb69ebb5d8fdf167647e421aa79900adaaa9b34d0
```
2. Initialize token holding
```bash
# Note: --definition-account-id uses a non-keycard account ID — replace with actual definition ID
wallet token init \
--definition-account-id "Public/$LEE_DEF_ID" \
--definition-account-id "Public/9bKmZ4n7PqVRxEtY3dWsQjA2cHrFT5LpDoGXM8wJuNv6" \
--holder-key-path "m/44'/60'/0'/0/2"
# Output
# Output:
Keycard PIN:
Transaction hash is d4442e32bf33efbac03672e3c5f6e181bc7e34f0911cf00ef915eeaee6787a5b
LEE holding initialized for keycard m/44'/60'/0'/0/2
```
```
3. Transfer tokens
```bash
# Send from a Keycard account to a local wallet account (--to-label) or another Keycard account (--to-key-path)
wallet token send \
--from-key-path "m/44'/60'/0'/0/1" \
--to-key-path "m/44'/60'/0'/0/2" \
--amount 1000
# Output:
Keycard PIN:
Transaction hash is cf1db3733c93c72b7a7c416403b558dbebcaf072f1797b09c2708f6dbc1ee58a
```
4. Mint tokens
```bash
wallet token mint \
--definition-key-path "m/44'/60'/0'/0/0" \
--holder-key-path "m/44'/60'/0'/0/2" \
--amount 5000
# Output:
Keycard PIN:
Transaction hash is 3a8f1b2e9c4d07a5fe6082b3d91c5e74f28160a7bc43091dde57f6a8b2c9e51f
```
5. Burn tokens
```bash
# Note: --definition uses a non-keycard account ID — replace with actual definition ID
wallet token burn \
--definition "Public/9bKmZ4n7PqVRxEtY3dWsQjA2cHrFT5LpDoGXM8wJuNv6" \
--holder-key-path "m/44'/60'/0'/0/2" \
--amount 500
# Output:
Keycard PIN:
Transaction hash is 7e4c2a91bf803d56fe19074b3c8a25d06e7f143829bc50addf6e1c78a4b09d23
```
### ATA program
The Associated Token Account (ATA) program creates deterministic token holding accounts derived from an owner account and a token definition. All write operations accept `--key-path` (or `--from-key-path`) to sign with a Keycard account instead of a local wallet account.
| Command | Key-path options | Description |
|-----------------------|---------------------|------------------------------------------------------------------------------|
| `wallet ata create` | `--key-path` | Creates (or idempotently no-ops) the ATA for the given owner + token pair |
| `wallet ata send` | `--from-key-path` | Transfers tokens from the owner's ATA to a recipient token holding account |
| `wallet ata burn` | `--key-path` | Burns tokens from the holder's ATA |
1. Derive ATA address (local, no signing)
```bash
# Note: --owner and --token-definition take raw account IDs without a privacy prefix
# Note: non-keycard account ID below — replace with actual owner/definition IDs
wallet ata address \
--owner "9bKmZ4n7PqVRxEtY3dWsQjA2cHrFT5LpDoGXM8wJuNv6" \
--token-definition "J9kXbdnzbZtH31RbZPxwky9bWbw3Tzr5jcfGbzkMwNUy"
# Output:
# Fh8d1HsqEUDzwg1vc1E9123nRpEGHJwwdqtiWu73JHPP
```
2. Create ATA (Keycard owner)
```bash
# Note: --token-definition takes a raw account ID without a privacy prefix
wallet ata create \
--key-path "m/44'/60'/0'/0/7" \
--token-definition "J9kXbdnzbZtH31RbZPxwky9bWbw3Tzr5jcfGbzkMwNUy"
# Output:
Keycard PIN:
Transaction hash is 5e1f3b8a2c094d67fe802945c3b71e50a016e28931bc04addf7e3c89b1a05f73
```
3. Send tokens from Keycard owner's ATA
```bash
# --from-key-path resolves the sender owner; --to is the recipient token holding (raw ID, no prefix)
# Note: --to value below is a non-keycard account ID — replace with the actual recipient holding ID
wallet ata send \
--from-key-path "m/44'/60'/0'/0/7" \
--token-definition "J9kXbdnzbZtH31RbZPxwky9bWbw3Tzr5jcfGbzkMwNUy" \
--to "Fh8d1HsqEUDzwg1vc1E9123nRpEGHJwwdqtiWu73JHPP" \
--amount 500
# Output:
Keycard PIN:
Transaction hash is 9d2a7e41b03c8f56970b5e38d15c7a83e126f39821bc05addf7e2c98d1b14f61
```
4. Burn tokens from Keycard owner's ATA
```bash
wallet ata burn \
--key-path "m/44'/60'/0'/0/7" \
--token-definition "J9kXbdnzbZtH31RbZPxwky9bWbw3Tzr5jcfGbzkMwNUy" \
--amount 200
# Output:
Keycard PIN:
Transaction hash is 2c5e9a72b08d4f67830b4e19d25c7b83f026e48931bc05ddaf7e3d89c1a04f92
```
### AMM program
| Command | Description |
|--------------------------------|---------------------------------------------------------------------|
| `wallet amm new` | ChainIndices (key paths) provided for definition and supply |
| `wallet amm swap-exact-input` | ChaindIndex (key path) to initialize Keycard public account |
| `wallet amm swap-exact-output` | ChainIndices (key paths) for `from` and `to` public accounts |
| `wallet amm add-liquidity` | ChainIndex (key path) for holding account |
| `wallet amm remove-liquidity` | ChainIndices (key paths) for definition and holding public accounts |
| Command | Key-path options | Description |
|--------------------------------|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| `wallet amm new` | `--user-holding-a-key-path`, `--user-holding-b-key-path` | Creates a new AMM pool; LP holding must be a local wallet account |
| `wallet amm swap-exact-input` | `--user-holding-a-key-path`, `--user-holding-b-key-path` | Swaps tokens; only the seller's key path is required for signing |
| `wallet amm swap-exact-output` | `--user-holding-a-key-path`, `--user-holding-b-key-path` | Swaps tokens specifying exact output; only the seller's key path is required|
| `wallet amm add-liquidity` | `--user-holding-a-key-path`, `--user-holding-b-key-path`, `--user-holding-lp-key-path` | Adds liquidity to a pool using Keycard accounts |
| `wallet amm remove-liquidity` | `--user-holding-a-key-path`, `--user-holding-b-key-path`, `--user-holding-lp-key-path` | Removes liquidity from a pool using Keycard accounts |
These commands work as expected, but uses `key-path` features to use a public account via Keycard.
These commands use `--key-path` options to sign with Keycard public accounts. For `wallet amm new`, the LP holding account must be a local wallet account (Keycard is not supported for the LP recipient in pool creation).
1. Create AMM pool
```bash
# Note: --user-holding-a-label and --user-holding-b-label use non-keycard wallet accounts — replace with actual labels or --user-holding-a/b-key-path for Keycard holdings
wallet amm new \
--user-holding-a-label my-lez-fund \
--user-holding-b-label my-lee-fund \
--user-holding-lp-label my-lp-fund \
--balance-a 10000 \
--balance-b 10000
# Output:
Transaction hash is abce4e4c771aab36107a0c590114d5ce597453602b8216a88d9164e7f7fd7854
```
2. Swap exact input (sell token B, receive token A)
```bash
# Provide key paths for both holdings; only the seller's path is used for signing
wallet amm swap-exact-input \
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
--user-holding-b-key-path "m/44'/60'/0'/0/5" \
--amount-in 500 \
--min-amount-out 1 \
--token-definition "J9kXbdnzbZtH31RbZPxwky9bWbw3Tzr5jcfGbzkMwNUy"
# Output:
Keycard PIN:
Transaction hash is 280d549ce3046dd5dc6e985076ffb3681f0196572eeac996473ca6cc5be070be
```
3. Swap exact output (buy token A, sell token B)
```bash
wallet amm swap-exact-output \
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
--user-holding-b-key-path "m/44'/60'/0'/0/5" \
--exact-amount-out 400 \
--max-amount-in 600 \
--token-definition "Fh8d1HsqEUDzwg1vc1E9123nRpEGHJwwdqtiWu73JHPP"
# Output:
Keycard PIN:
Transaction hash is 1f7a3c5e9d82b04610fe2875c3a91b6d408e53f2bc7409adde16f0c78b2e4d9a
```
4. Add liquidity
```bash
wallet amm add-liquidity \
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
--user-holding-b-key-path "m/44'/60'/0'/0/5" \
--user-holding-lp-key-path "m/44'/60'/0'/0/6" \
--max-amount-a 1000 \
--max-amount-b 1000 \
--min-amount-lp 1
# Output:
Keycard PIN:
Transaction hash is 4b8e2d71a09c3f56870b4e29d15c7a83e026f48931bc05addf7e2d89c1b04f72
```
5. Remove liquidity
```bash
wallet amm remove-liquidity \
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
--user-holding-b-key-path "m/44'/60'/0'/0/5" \
--user-holding-lp-key-path "m/44'/60'/0'/0/6" \
--balance-lp 500 \
--min-amount-a 1 \
--min-amount-b 1
# Output:
Keycard PIN:
Transaction hash is 8c4f1a93e27b065d3f9084c5b72e1d46a015e38920ad71bcce48f3d07b59a26e
```

View File

@ -123,6 +123,7 @@ unsafe extern "C" {
to_keys: *const FfiPrivateAccountKeys,
to_identifier: *const FfiU128,
amount: *const [u8; 16],
key_path: *const c_char,
out_result: *mut FfiTransferResult,
) -> error::WalletFfiError;
@ -131,6 +132,7 @@ unsafe extern "C" {
from: *const FfiBytes32,
to: *const FfiBytes32,
amount: *const [u8; 16],
key_path: *const c_char,
out_result: *mut FfiTransferResult,
) -> error::WalletFfiError;
@ -140,6 +142,7 @@ unsafe extern "C" {
to_keys: *const FfiPrivateAccountKeys,
to_identifier: *const FfiU128,
amount: *const [u8; 16],
key_path: *const c_char,
out_result: *mut FfiTransferResult,
) -> error::WalletFfiError;
@ -154,6 +157,7 @@ unsafe extern "C" {
fn wallet_ffi_register_private_account(
handle: *mut WalletHandle,
account_id: *const FfiBytes32,
key_path: *const c_char,
out_result: *mut FfiTransferResult,
) -> error::WalletFfiError;
@ -701,6 +705,7 @@ fn wallet_ffi_init_private_account_auth_transfer() -> Result<()> {
wallet_ffi_register_private_account(
wallet_ffi_handle,
&raw const out_account_id,
std::ptr::null(),
&raw mut transfer_result,
);
}
@ -818,6 +823,7 @@ fn test_wallet_ffi_transfer_shielded() -> Result<()> {
&raw const to_keys,
&raw const to_identifier,
&raw const amount,
std::ptr::null(),
&raw mut transfer_result,
);
}
@ -882,6 +888,7 @@ fn test_wallet_ffi_transfer_deshielded() -> Result<()> {
&raw const from,
&raw const to,
&raw const amount,
std::ptr::null(),
&raw mut transfer_result,
);
}
@ -953,6 +960,7 @@ fn test_wallet_ffi_transfer_private() -> Result<()> {
&raw const to_keys,
&raw const to_identifier,
&raw const amount,
std::ptr::null(),
&raw mut transfer_result,
);
}

View File

@ -1,188 +1,426 @@
#!/usr/bin/env bash
# keycard_tests_2.sh — comprehensive token + AMM keycard integration tests.
#
# Prerequisites:
# 1. Run wallet_with_keycard.sh once to install dependencies.
# 2. Reset the local chain so all accounts are uninitialized.
# 3. Keycard reader inserted with card loaded.
#
# Keycard path layout:
# path 0 → LEZ token definition (keycard)
# path 1 → LEZ token supply (keycard)
# path 2 → LEE token definition (keycard)
# path 3 → LEE token supply (keycard)
# path 4 → LEZ holding (keycard — transfers, mint, burn, swap, liquidity)
# path 5 → LEE holding (keycard — swap, add/remove liquidity)
# path 6 → LP holding (keycard — add/remove liquidity)
# path 7 → ATA owner (keycard — ATA create, send, burn)
#
# Non-keycard accounts:
# pub-receiver → public account (target for keycard → public token transfer)
# priv-receiver → private account (target for keycard → private token transfer)
# amm-lez-fund → public LEZ holding used to seed the AMM pool
# amm-lee-fund → public LEE holding used to seed the AMM pool
# (LP holding for amm new is created fresh each run — no persistent label)
source venv/bin/activate
export KEYCARD_PIN=111111
# =============================================================================
# Keycard setup
# =============================================================================
echo ""
echo "=== Create LEZ and LEE token definitions (without keycard) ==="
echo "=== Keycard setup ==="
wallet keycard available
wallet keycard load --mnemonic "fashion degree mountain wool question damp current pond grow dolphin chronic then"
wallet account new public --label lez-def
wallet account new public --label lez-supply
wallet account new public --label lee-def
wallet account new public --label lee-supply
# =============================================================================
# Create non-keycard wallet accounts
# =============================================================================
echo ""
echo "=== Create non-keycard accounts ==="
wallet account new public --label pub-receiver 2>/dev/null || true
sleep 5
LEZ_DEF_ID=$(wallet account id --account-label lez-def)
LEE_DEF_ID=$(wallet account id --account-label lee-def)
wallet account new public --label amm-lez-fund 2>/dev/null || true
wallet account new public --label amm-lee-fund 2>/dev/null || true
wallet account new public --label amm-lp-fund 2>/dev/null || true
# =============================================================================
# (1) Create LEZ token — definition AND supply via keycard paths
# =============================================================================
echo ""
echo "=== (1) Create LEZ token (keycard def=path0, supply=path1) ==="
wallet token new \
--definition-account-label lez-def \
--supply-account-label lez-supply \
--total-supply 100000 \
--name LEZ
--definition-key-path "m/44'/60'/0'/0/0" \
--supply-key-path "m/44'/60'/0'/0/1" \
--name LEZ \
--total-supply 100000
echo "LEZ token created"
# =============================================================================
# (2) Create LEE token — definition AND supply via keycard paths
# =============================================================================
echo ""
echo "=== (2) Create LEE token (keycard def=path2, supply=path3) ==="
wallet token new \
--definition-account-label lee-def \
--supply-account-label lee-supply \
--total-supply 100000 \
--name LEE
--definition-key-path "m/44'/60'/0'/0/2" \
--supply-key-path "m/44'/60'/0'/0/3" \
--name LEE \
--total-supply 100000
echo "LEE token created"
# =============================================================================
# Initialize LEE token holding accounts:
# - two public keycard holders (paths 2 and 3)
# - one private holder (without keycard)
# =============================================================================
echo ""
echo "=== Initialize LEE/LEZ token holding accounts ==="
sleep 15
wallet token init \
--definition-account-id "Public/$LEE_DEF_ID" \
--holder-key-path "m/44'/60'/0'/0/2"
echo "LEE holding initialized for keycard m/44'/60'/0'/0/2"
LEZ_DEF_ID=$(wallet account id --key-path "m/44'/60'/0'/0/0")
LEE_DEF_ID=$(wallet account id --key-path "m/44'/60'/0'/0/2")
echo "LEZ definition ID: $LEZ_DEF_ID"
echo "LEE definition ID: $LEE_DEF_ID"
wallet token init \
--definition-account-id "Public/$LEE_DEF_ID" \
--holder-key-path "m/44'/60'/0'/0/3"
echo "LEE holding initialized for keycard m/44'/60'/0'/0/3"
# For shielded transfer
wallet account new private --label lee-priv-holder 2>/dev/null || true
wallet token init \
--definition-account-id "Public/$LEE_DEF_ID" \
--holder-account-label lee-priv-holder
echo "Private LEE holding initialized"
# Fund the two keycard LEE holdings from the supply.
# Only the sender (lee-supply, stored key) needs to sign for a token Transfer
# to an already-initialized holding.
wallet token send \
--from-label lee-supply \
--to-key-path "m/44'/60'/0'/0/2" \
--amount 5000
echo "Transferred 5000 LEE → keycard path 2"
wallet token send \
--from-label lee-supply \
--to-key-path "m/44'/60'/0'/0/3" \
--amount 5000
echo "Transferred 5000 LEE → keycard path 3"
sleep 5
echo "Keycard path 2 LEE state (balance should be 5000):"
echo "Keycard path 0 (LEZ definition) state:"
wallet account get --key-path "m/44'/60'/0'/0/0"
echo "Keycard path 1 (LEZ supply) state:"
wallet account get --key-path "m/44'/60'/0'/0/1"
echo "Keycard path 2 (LEE definition) state:"
wallet account get --key-path "m/44'/60'/0'/0/2"
echo "Keycard path 3 LEE state (balance should be 5000):"
echo "Keycard path 3 (LEE supply) state:"
wallet account get --key-path "m/44'/60'/0'/0/3"
# =============================================================================
# Shielded (public → private) LEE transfer from keycard holding to the
# private LEE holding account.
# Initialize token holding accounts
# =============================================================================
echo ""
echo "=== Test Shielded transfer keycard LEE holding → private LEE holding ==="
echo "=== Initialize token holding accounts ==="
wallet token send \
--from-key-path "m/44'/60'/0'/0/2" \
--to-label lee-priv-holder \
--amount 500
echo "Shielded transfer complete (500 LEE: path-2 keycard → private holder)"
wallet account sync-private
echo "Private LEE holder state (balance should be 500):"
wallet account get --account-label lee-priv-holder
# =============================================================================
# Create AMM pool for LEZ/LEE (without keycard)
# =============================================================================
echo ""
echo "=== Test Create AMM pool for LEZ/LEE (without keycard) ==="
wallet account new public --label amm-lp-lez-holding 2>/dev/null || true
wallet account new public --label amm-lp-lee-holding 2>/dev/null || true
wallet account new public --label amm-lp-lp-holding 2>/dev/null || true
wallet token init \
--definition-account-id "Public/$LEZ_DEF_ID" \
--holder-account-label amm-lp-lez-holding
wallet token init \
--definition-account-id "Public/$LEE_DEF_ID" \
--holder-account-label amm-lp-lee-holding
wallet token send --from-label lez-supply --to-label amm-lp-lez-holding --amount 40000
wallet token send --from-label lee-supply --to-label amm-lp-lee-holding --amount 40000
wallet amm new \
--user-holding-a-label amm-lp-lez-holding \
--user-holding-b-label amm-lp-lee-holding \
--user-holding-lp-label amm-lp-lp-holding \
--balance-a 40000 \
--balance-b 40000
echo "AMM pool created for LEZ/LEE"
# =============================================================================
# Swaps, add liquidity, remove liquidity using keycard holding accounts.
#
# Path layout:
# path 2 → LEE holding (4500 LEE after step 4)
# path 3 → LEE holding (5000 LEE)
# path 4 → fresh; initialized below as LEZ holding (receives swapped LEZ)
# =============================================================================
echo ""
echo "=== Test Initialize LEZ holding for keycard path 4 (swap output) ==="
# Keycard path 4: LEZ holding
wallet token init \
--definition-account-id "Public/$LEZ_DEF_ID" \
--holder-key-path "m/44'/60'/0'/0/4"
echo "LEZ holding initialized for keycard m/44'/60'/0'/0/4"
echo "LEZ holding initialized for keycard path 4"
# Resolve raw account IDs needed for the swap --user-holding-* args.
PATH2_ID=$(wallet account id --key-path "m/44'/60'/0'/0/2")
PATH3_ID=$(wallet account id --key-path "m/44'/60'/0'/0/3")
PATH4_ID=$(wallet account id --key-path "m/44'/60'/0'/0/4")
# Keycard path 5: LEE holding
wallet token init \
--definition-account-id "Public/$LEE_DEF_ID" \
--holder-key-path "m/44'/60'/0'/0/5"
echo "LEE holding initialized for keycard path 5"
echo "Path 2: $PATH2_ID Path 3: $PATH3_ID Path 4: $PATH4_ID"
echo "LEE def ID: $LEE_DEF_ID"
# pub-receiver: public LEZ holding (for token transfer test)
wallet token init \
--definition-account-id "Public/$LEZ_DEF_ID" \
--holder-account-label pub-receiver
echo "LEZ holding initialized for pub-receiver"
# AMM seed accounts
wallet token init \
--definition-account-id "Public/$LEZ_DEF_ID" \
--holder-account-label amm-lez-fund
wallet token init \
--definition-account-id "Public/$LEE_DEF_ID" \
--holder-account-label amm-lee-fund
echo "AMM seed holdings initialized"
# =============================================================================
# Fund keycard holdings and AMM seed accounts from supply
# =============================================================================
echo ""
echo "=== Swap LEE → LEZ (path 2 sells LEE, path 4 receives LEZ) ==="
echo "=== Fund keycard holdings and AMM seed accounts ==="
wallet token send \
--from-key-path "m/44'/60'/0'/0/1" \
--to-key-path "m/44'/60'/0'/0/4" \
--amount 20000
echo "Transferred 20000 LEZ → keycard path 4"
wallet token send \
--from-key-path "m/44'/60'/0'/0/3" \
--to-key-path "m/44'/60'/0'/0/5" \
--amount 20000
echo "Transferred 20000 LEE → keycard path 5"
wallet token send \
--from-key-path "m/44'/60'/0'/0/1" \
--to-label amm-lez-fund \
--amount 10000
echo "Transferred 10000 LEZ → amm-lez-fund"
wallet token send \
--from-key-path "m/44'/60'/0'/0/3" \
--to-label amm-lee-fund \
--amount 10000
echo "Transferred 10000 LEE → amm-lee-fund"
sleep 15
echo "Keycard path 4 (LEZ holding) state (balance should be 20000):"
wallet account get --key-path "m/44'/60'/0'/0/4"
echo "Keycard path 5 (LEE holding) state (balance should be 20000):"
wallet account get --key-path "m/44'/60'/0'/0/5"
echo "amm-lez-fund state (balance should be 10000):"
wallet account get --account-label amm-lez-fund
echo "amm-lee-fund state (balance should be 10000):"
wallet account get --account-label amm-lee-fund
# =============================================================================
# (3) Token transfer: keycard path 4 (LEZ) → public account
# =============================================================================
echo ""
echo "=== (3) Token transfer: keycard path 4 → pub-receiver (public) ==="
wallet token send \
--from-key-path "m/44'/60'/0'/0/4" \
--to-label pub-receiver \
--amount 1000
echo "Transferred 1000 LEZ: keycard path 4 → pub-receiver"
sleep 15
echo "Keycard path 4 (LEZ) state (balance should be 19000):"
wallet account get --key-path "m/44'/60'/0'/0/4"
echo "pub-receiver state (balance should be 1000):"
wallet account get --account-label pub-receiver
# =============================================================================
# (4) Token transfer: keycard path 4 (LEZ) → private account (shielded)
# =============================================================================
echo ""
echo "=== (4) Token transfer: keycard path 4 → priv-receiver (private, shielded) ==="
PRIV_RECEIVER=$(wallet account new private | grep -o 'Private/[^[:space:]]*' | head -1)
echo "Fresh private receiver account: $PRIV_RECEIVER"
wallet token send \
--from-key-path "m/44'/60'/0'/0/4" \
--to "$PRIV_RECEIVER" \
--amount 500
echo "Shielded transfer of 500 LEZ: keycard path 4 → $PRIV_RECEIVER"
wallet account sync-private
sleep 15
echo "Keycard path 4 (LEZ) state (balance should be 18500):"
wallet account get --key-path "m/44'/60'/0'/0/4"
echo "priv-receiver state (balance should be 500):"
wallet account get --account-id "$PRIV_RECEIVER"
# =============================================================================
# (5) Token mint with keycard — definition signed by keycard path 0
# =============================================================================
echo ""
echo "=== (5) Token mint: keycard def path 0 mints 2000 LEZ to keycard path 4 ==="
wallet token mint \
--definition-key-path "m/44'/60'/0'/0/0" \
--holder-key-path "m/44'/60'/0'/0/4" \
--amount 2000
echo "Minted 2000 LEZ to keycard path 4"
sleep 15
echo "Keycard path 0 (LEZ definition) state (total supply should have increased):"
wallet account get --key-path "m/44'/60'/0'/0/0"
echo "Keycard path 4 (LEZ holding) state (balance should be 20500):"
wallet account get --key-path "m/44'/60'/0'/0/4"
# =============================================================================
# (6) Token burn with keycard — holder is keycard path 4
# =============================================================================
echo ""
echo "=== (6) Token burn: keycard path 4 burns 500 LEZ ==="
wallet token burn \
--definition "Public/$LEZ_DEF_ID" \
--holder-key-path "m/44'/60'/0'/0/4" \
--amount 500
echo "Burned 500 LEZ from keycard path 4"
sleep 15
echo "Keycard path 0 (LEZ definition) state (total supply should reflect burn):"
wallet account get --key-path "m/44'/60'/0'/0/0"
echo "Keycard path 4 (LEZ holding) state (balance should be 20000):"
wallet account get --key-path "m/44'/60'/0'/0/4"
# =============================================================================
# (7) Create AMM pool for LEZ/LEE — without keycard
# =============================================================================
echo ""
echo "=== (7) Create AMM pool for LEZ/LEE (without keycard) ==="
wallet amm new \
--user-holding-a-label amm-lez-fund \
--user-holding-b-label amm-lee-fund \
--user-holding-lp-label amm-lp-fund \
--balance-a 10000 \
--balance-b 10000
echo "AMM pool created for LEZ/LEE"
sleep 15
echo "amm-lez-fund state (balance should be 0 — contributed to pool):"
wallet account get --account-label amm-lez-fund
echo "amm-lee-fund state (balance should be 0 — contributed to pool):"
wallet account get --account-label amm-lee-fund
echo "Initial LP holding state (should hold initial LP tokens):"
wallet account get --account-label amm-lp-fund
LP_DEF_ID=$(wallet account get --account-label amm-lp-fund | grep -o '"definition_id":"[^"]*"' | awk -F'"' '{print $4}')
echo "LP token definition ID: $LP_DEF_ID"
# =============================================================================
# (8) Swap tokens owned by keycard accounts
# keycard path 5 (LEE) sells 500 LEE; keycard path 4 (LEZ) receives LEZ
# =============================================================================
echo ""
echo "=== (8) Swap: keycard path 5 sells 500 LEE, keycard path 4 receives LEZ ==="
wallet amm swap-exact-input \
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
--user-holding-b-key-path "m/44'/60'/0'/0/2" \
--amount-in 100 \
--user-holding-b-key-path "m/44'/60'/0'/0/5" \
--amount-in 500 \
--min-amount-out 1 \
--token-definition "$LEE_DEF_ID" \
echo "Swap LEE→LEZ complete via keycard"
--token-definition "$LEE_DEF_ID"
echo "Swap LEE LEZ complete via keycard"
sleep 15
echo "Path 4 (LEZ) state:"
echo "Keycard path 4 (LEZ holding) state (balance should have increased):"
wallet account get --key-path "m/44'/60'/0'/0/4"
echo "Path 2 (LEE) state:"
wallet account get --key-path "m/44'/60'/0'/0/2"
echo "Keycard path 5 (LEE holding) state (balance should have decreased by 500):"
wallet account get --key-path "m/44'/60'/0'/0/5"
# =============================================================================
# (9) Add liquidity — keycard accounts for holding A (path 4), B (path 5), LP (path 6)
# =============================================================================
echo ""
echo "=== (9) Initialize LP holding (keycard path 6) before add-liquidity ==="
wallet token init \
--definition-account-id "Public/$LP_DEF_ID" \
--holder-key-path "m/44'/60'/0'/0/6"
echo "Keycard path 6 (LP holding) initialized"
sleep 15
echo "Keycard path 6 (LP holding) state (after init):"
wallet account get --key-path "m/44'/60'/0'/0/6"
echo ""
echo "=== Test (6c): Add liquidity (path 4 LEZ + path 3 LEE) ==="
echo "=== (9) Add liquidity (keycard path 4=LEZ, path 5=LEE, path 6=LP) ==="
wallet amm add-liquidity \
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
--user-holding-b-key-path "m/44'/60'/0'/0/3" \
--user-holding-lp-label "m/44'/60'/0'/0/5" \
--min-amount-lp 1 \
--max-amount-a 200 \
--max-amount-b 200
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
--user-holding-b-key-path "m/44'/60'/0'/0/5" \
--user-holding-lp-key-path "m/44'/60'/0'/0/6" \
--max-amount-a 1000 \
--max-amount-b 1000 \
--min-amount-lp 1
echo "Add liquidity complete via keycard"
sleep 15
echo "Keycard path 4 (LEZ holding) state (balance should have decreased):"
wallet account get --key-path "m/44'/60'/0'/0/4"
echo "Keycard path 5 (LEE holding) state (balance should have decreased):"
wallet account get --key-path "m/44'/60'/0'/0/5"
echo "Keycard path 6 (LP holding) state (should have received LP tokens):"
wallet account get --key-path "m/44'/60'/0'/0/6"
# =============================================================================
# (10) Remove liquidity — keycard accounts for holding A (path 4), B (path 5), LP (path 6)
# =============================================================================
echo ""
echo "=== Test (6d): Remove liquidity (LP from amm-lp-lp-holding) ==="
echo "=== (10) Remove liquidity (keycard path 4=LEZ, path 5=LEE, path 6=LP) ==="
wallet amm remove-liquidity \
--user-holding-a-label "m/44'/60'/0'/0/4"\
--user-holding-b-label "m/44'/60'/0'/0/3" \
--user-holding-lp-label amm-lp-lp-holding \
--balance-lp 1000 \
--user-holding-a-key-path "m/44'/60'/0'/0/4" \
--user-holding-b-key-path "m/44'/60'/0'/0/5" \
--user-holding-lp-key-path "m/44'/60'/0'/0/6" \
--balance-lp 500 \
--min-amount-a 1 \
--min-amount-b 1
echo "Remove liquidity complete"
echo "Remove liquidity complete via keycard"
sleep 15
echo "Keycard path 4 (LEZ holding) state (balance should have increased):"
wallet account get --key-path "m/44'/60'/0'/0/4"
echo "Keycard path 5 (LEE holding) state (balance should have increased):"
wallet account get --key-path "m/44'/60'/0'/0/5"
echo "Keycard path 6 (LP holding) state (balance should have decreased):"
wallet account get --key-path "m/44'/60'/0'/0/6"
# =============================================================================
# (11) ATA create — keycard path 7 as owner for LEZ
# =============================================================================
echo ""
echo "=== (11) ATA create: keycard path 7 as owner, LEZ token ==="
ATA_OWNER_ID=$(wallet account id --key-path "m/44'/60'/0'/0/7")
echo "ATA owner (keycard path 7): $ATA_OWNER_ID"
wallet ata create \
--key-path "m/44'/60'/0'/0/7" \
--token-definition "$LEZ_DEF_ID"
echo "ATA created for keycard path 7 / LEZ"
sleep 15
LEZ_ATA_ID=$(wallet ata address --owner "$ATA_OWNER_ID" --token-definition "$LEZ_DEF_ID")
echo "Keycard path 7 LEZ ATA ID: $LEZ_ATA_ID"
echo "ATA state (should be initialized with zero balance):"
wallet account get --account-id "Public/$LEZ_ATA_ID"
# Fund the ATA from LEZ supply (path 1) — setup for tests 12 and 13
wallet token send \
--from-key-path "m/44'/60'/0'/0/1" \
--to "Public/$LEZ_ATA_ID" \
--amount 3000
echo "Funded keycard path 7 ATA with 3000 LEZ"
sleep 15
echo "ATA state after funding (balance should be 3000):"
wallet account get --account-id "Public/$LEZ_ATA_ID"
# =============================================================================
# (12) ATA send — keycard path 7's ATA → pub-receiver's ATA
# =============================================================================
echo ""
echo "=== (12) ATA send: keycard path 7's ATA → pub-receiver's ATA ==="
PUB_RECEIVER_ID=$(wallet account id --account-label pub-receiver)
wallet ata create \
--owner "Public/$PUB_RECEIVER_ID" \
--token-definition "$LEZ_DEF_ID"
echo "ATA created for pub-receiver / LEZ"
sleep 15
PUB_RECEIVER_ATA_ID=$(wallet ata address --owner "$PUB_RECEIVER_ID" --token-definition "$LEZ_DEF_ID")
echo "pub-receiver LEZ ATA ID: $PUB_RECEIVER_ATA_ID"
echo "pub-receiver ATA state (should be initialized with zero balance):"
wallet account get --account-id "Public/$PUB_RECEIVER_ATA_ID"
wallet ata send \
--from-key-path "m/44'/60'/0'/0/7" \
--token-definition "$LEZ_DEF_ID" \
--to "$PUB_RECEIVER_ATA_ID" \
--amount 500
echo "Sent 500 LEZ: keycard path 7 ATA → pub-receiver ATA"
sleep 15
echo "Keycard path 7 ATA state (balance should be 2500):"
wallet account get --account-id "Public/$LEZ_ATA_ID"
echo "pub-receiver ATA state (balance should be 500):"
wallet account get --account-id "Public/$PUB_RECEIVER_ATA_ID"
# =============================================================================
# (13) ATA burn — keycard path 7's ATA burns 200 LEZ
# =============================================================================
echo ""
echo "=== (13) ATA burn: keycard path 7's ATA burns 200 LEZ ==="
wallet ata burn \
--key-path "m/44'/60'/0'/0/7" \
--token-definition "$LEZ_DEF_ID" \
--amount 200
echo "Burned 200 LEZ from keycard path 7 ATA"
sleep 15
echo "Keycard path 7 ATA state (balance should be 2300):"
wallet account get --account-id "Public/$LEZ_ATA_ID"
echo "LEZ definition state (total supply should reflect burn):"
wallet account get --key-path "m/44'/60'/0'/0/0"
echo ""
echo "=== All keycard tests finished ==="
echo "=== All keycard token + AMM + ATA tests finished ==="

View File

@ -223,7 +223,8 @@ pub enum AmmProgramAgnosticSubcommand {
#[arg(
long,
conflicts_with = "user_holding_lp_label",
required_unless_present = "user_holding_lp_label"
conflicts_with = "user_holding_lp_key_path",
required_unless_present_any = ["user_holding_lp_label", "user_holding_lp_key_path"]
)]
user_holding_lp: Option<String>,
/// User holding LP account label (alternative to --user-holding-lp).
@ -256,7 +257,8 @@ pub enum AmmProgramAgnosticSubcommand {
#[arg(
long,
conflicts_with = "user_holding_a_label",
required_unless_present = "user_holding_a_label"
conflicts_with = "user_holding_a_key_path",
required_unless_present_any = ["user_holding_a_label", "user_holding_a_key_path"]
)]
user_holding_a: Option<String>,
/// User holding A account label (alternative to --user-holding-a).
@ -273,7 +275,8 @@ pub enum AmmProgramAgnosticSubcommand {
#[arg(
long,
conflicts_with = "user_holding_b_label",
required_unless_present = "user_holding_b_label"
conflicts_with = "user_holding_b_key_path",
required_unless_present_any = ["user_holding_b_label", "user_holding_b_key_path"]
)]
user_holding_b: Option<String>,
/// User holding B account label (alternative to --user-holding-b).

View File

@ -83,7 +83,11 @@ impl Amm<'_> {
.get_accounts_nonces(vec![user_holding_lp])
.await
.map_err(ExecutionFailureKind::SequencerError)?;
nonces.extend(lp_nonces);
if lp_nonces.is_empty() {
nonces.push(nssa_core::account::Nonce(0));
} else {
nonces.extend(lp_nonces);
}
} else {
println!(
"Liquidity pool tokens receiver's account ({user_holding_lp}) private key not found in wallet. Proceeding with only liquidity provider's keys."
@ -243,22 +247,22 @@ impl Amm<'_> {
.unwrap();
let msg_hash = message.hash();
let witness_set = if let (Some(kp_a), Some(kp_b)) =
(user_holding_a_key_path, user_holding_b_key_path)
{
let seller_key_path = if definition_token_a_id == token_definition_id_in {
user_holding_a_key_path
} else {
user_holding_b_key_path
};
let witness_set = if let Some(kp) = seller_key_path {
let pin = crate::helperfunctions::read_pin().map_err(|e| {
ExecutionFailureKind::KeycardError(pyo3::PyErr::new::<
pyo3::exceptions::PyRuntimeError,
_,
>(e.to_string()))
})?;
let (sig1, pk1) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
&pin, kp_a, &msg_hash,
let (sig, pk) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
&pin, kp, &msg_hash,
)?;
let (sig2, pk2) = keycard_wallet::KeycardWallet::sign_message_for_path_with_connect(
&pin, kp_b, &msg_hash,
)?;
nssa::public_transaction::WitnessSet::from_list(&message, &[sig1, sig2], &[pk1, pk2])
nssa::public_transaction::WitnessSet::from_list(&message, &[sig], &[pk])
.map_err(ExecutionFailureKind::TransactionBuildError)?
} else {
let signing_key = self