Skip to content

Commit 0551e01

Browse files
docs: update FFI API documentation
1 parent fed440f commit 0551e01

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

key-wallet-ffi/FFI_API.md

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This document provides a comprehensive reference for all FFI (Foreign Function I
44

55
**Auto-generated**: This documentation is automatically generated from the source code. Do not edit manually.
66

7-
**Total Functions**: 236
7+
**Total Functions**: 238
88

99
## Table of Contents
1010

@@ -68,7 +68,7 @@ Functions: 19
6868

6969
### Wallet Operations
7070

71-
Functions: 57
71+
Functions: 58
7272

7373
| Function | Description | Module |
7474
|----------|-------------|--------|
@@ -100,7 +100,8 @@ Functions: 57
100100
| `wallet_add_account` | Add an account to the wallet without xpub # Safety This function dereferenc... | wallet |
101101
| `wallet_add_account_with_string_xpub` | Add an account to the wallet with xpub as string # Safety This function der... | wallet |
102102
| `wallet_add_account_with_xpub_bytes` | Add an account to the wallet with xpub as byte array # Safety This function... | wallet |
103-
| `wallet_build_transaction` | Build a transaction # Safety - `wallet` must be a valid pointer to an FFIWa... | transaction |
103+
| `wallet_build_and_sign_transaction` | Build and sign a transaction using the wallet's managed info This is the rec... | transaction |
104+
| `wallet_build_transaction` | Build a transaction (unsigned) This creates an unsigned transaction | transaction |
104105
| `wallet_check_transaction` | Check if a transaction belongs to the wallet using ManagedWalletInfo # Safet... | transaction |
105106
| `wallet_create_from_mnemonic` | Create a new wallet from mnemonic (backward compatibility - single network) ... | wallet |
106107
| `wallet_create_from_mnemonic_with_options` | Create a new wallet from mnemonic with options # Safety - `mnemonic` must b... | wallet |
@@ -250,7 +251,7 @@ Functions: 10
250251

251252
### Transaction Management
252253

253-
Functions: 13
254+
Functions: 14
254255

255256
| Function | Description | Module |
256257
|----------|-------------|--------|
@@ -263,6 +264,7 @@ Functions: 13
263264
| `transaction_deserialize` | Deserialize a transaction # Safety - `data` must be a valid pointer to seria... | transaction |
264265
| `transaction_destroy` | Destroy a transaction # Safety - `tx` must be a valid pointer to an FFITrans... | transaction |
265266
| `transaction_get_txid` | Get the transaction ID # Safety - `tx` must be a valid pointer to an FFITran... | transaction |
267+
| `transaction_get_txid_from_bytes` | Get transaction ID from raw transaction bytes # Safety - `tx_bytes` must be ... | transaction |
266268
| `transaction_serialize` | Serialize a transaction # Safety - `tx` must be a valid pointer to an FFITra... | transaction |
267269
| `transaction_sighash` | Calculate signature hash for an input # Safety - `tx` must be a valid pointe... | transaction |
268270
| `transaction_sign_input` | Sign a transaction input # Safety - `tx` must be a valid pointer to an FFITr... | transaction |
@@ -1130,14 +1132,30 @@ This function dereferences raw pointers. The caller must ensure that: - The wall
11301132

11311133
---
11321134

1135+
#### `wallet_build_and_sign_transaction`
1136+
1137+
```c
1138+
wallet_build_and_sign_transaction(managed_wallet: *mut FFIManagedWalletInfo, wallet: *const FFIWallet, network: FFINetwork, account_index: c_uint, outputs: *const FFITxOutput, outputs_count: usize, fee_per_kb: u64, current_height: u32, tx_bytes_out: *mut *mut u8, tx_len_out: *mut usize, error: *mut FFIError,) -> bool
1139+
```
1140+
1141+
**Description:**
1142+
Build and sign a transaction using the wallet's managed info This is the recommended way to build transactions. It handles: - UTXO selection using coin selection algorithms - Fee calculation - Change address generation - Transaction signing # Safety - `managed_wallet` must be a valid pointer to an FFIManagedWalletInfo - `wallet` must be a valid pointer to an FFIWallet - `network` must be a valid FFINetwork - `outputs` must be a valid pointer to an array of FFITxOutput with at least `outputs_count` elements - `tx_bytes_out` must be a valid pointer to store the transaction bytes pointer - `tx_len_out` must be a valid pointer to store the transaction length - `error` must be a valid pointer to an FFIError - The returned transaction bytes must be freed with `transaction_bytes_free`
1143+
1144+
**Safety:**
1145+
- `managed_wallet` must be a valid pointer to an FFIManagedWalletInfo - `wallet` must be a valid pointer to an FFIWallet - `network` must be a valid FFINetwork - `outputs` must be a valid pointer to an array of FFITxOutput with at least `outputs_count` elements - `tx_bytes_out` must be a valid pointer to store the transaction bytes pointer - `tx_len_out` must be a valid pointer to store the transaction length - `error` must be a valid pointer to an FFIError - The returned transaction bytes must be freed with `transaction_bytes_free`
1146+
1147+
**Module:** `transaction`
1148+
1149+
---
1150+
11331151
#### `wallet_build_transaction`
11341152

11351153
```c
11361154
wallet_build_transaction(wallet: *mut FFIWallet, _network: FFINetworks, account_index: c_uint, outputs: *const FFITxOutput, outputs_count: usize, fee_per_kb: u64, tx_bytes_out: *mut *mut u8, tx_len_out: *mut usize, error: *mut FFIError,) -> bool
11371155
```
11381156

11391157
**Description:**
1140-
Build a transaction # Safety - `wallet` must be a valid pointer to an FFIWallet - `outputs` must be a valid pointer to an array of FFITxOutput with at least `outputs_count` elements - `tx_bytes_out` must be a valid pointer to store the transaction bytes pointer - `tx_len_out` must be a valid pointer to store the transaction length - `error` must be a valid pointer to an FFIError - The returned transaction bytes must be freed with `transaction_bytes_free`
1158+
Build a transaction (unsigned) This creates an unsigned transaction. Use wallet_sign_transaction to sign it afterward. For a combined build+sign operation, use wallet_build_and_sign_transaction. # Safety - `wallet` must be a valid pointer to an FFIWallet - `outputs` must be a valid pointer to an array of FFITxOutput with at least `outputs_count` elements - `tx_bytes_out` must be a valid pointer to store the transaction bytes pointer - `tx_len_out` must be a valid pointer to store the transaction length - `error` must be a valid pointer to an FFIError - The returned transaction bytes must be freed with `transaction_bytes_free`
11411159

11421160
**Safety:**
11431161
- `wallet` must be a valid pointer to an FFIWallet - `outputs` must be a valid pointer to an array of FFITxOutput with at least `outputs_count` elements - `tx_bytes_out` must be a valid pointer to store the transaction bytes pointer - `tx_len_out` must be a valid pointer to store the transaction length - `error` must be a valid pointer to an FFIError - The returned transaction bytes must be freed with `transaction_bytes_free`
@@ -3318,6 +3336,22 @@ Get the transaction ID # Safety - `tx` must be a valid pointer to an FFITransac
33183336

33193337
---
33203338

3339+
#### `transaction_get_txid_from_bytes`
3340+
3341+
```c
3342+
transaction_get_txid_from_bytes(tx_bytes: *const u8, tx_len: usize, error: *mut FFIError,) -> *mut c_char
3343+
```
3344+
3345+
**Description:**
3346+
Get transaction ID from raw transaction bytes # Safety - `tx_bytes` must be a valid pointer to transaction bytes - `tx_len` must be the correct length of the transaction - `error` must be a valid pointer to an FFIError # Returns - Pointer to null-terminated hex string of TXID (must be freed with string_free) - NULL on error
3347+
3348+
**Safety:**
3349+
- `tx_bytes` must be a valid pointer to transaction bytes - `tx_len` must be the correct length of the transaction - `error` must be a valid pointer to an FFIError
3350+
3351+
**Module:** `transaction`
3352+
3353+
---
3354+
33213355
#### `transaction_serialize`
33223356

33233357
```c

0 commit comments

Comments
 (0)