Skip to content

Commit 576703c

Browse files
feat: update version to 0.40.0 and implement user agent configuration (#133)
* feat: update version to 0.40.0 and implement user agent configuration * updated docs * fix * fix
1 parent 1f83438 commit 576703c

File tree

22 files changed

+282
-237
lines changed

22 files changed

+282
-237
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["dash", "dash-network", "dash-network-ffi", "hashes", "internals", "f
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.39.6"
6+
version = "0.40.0"
77

88
[patch.crates-io]
99
dashcore_hashes = { path = "hashes" }

dash-network-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dash-network-ffi"
3-
version.workspace = true
3+
version = { workspace = true }
44
edition = "2021"
55
authors = ["Quantum Explorer <quantum@dash.org>"]
66
license = "CC0-1.0"

dash-network/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Add this to your `Cargo.toml`:
1919

2020
```toml
2121
[dependencies]
22-
dash-network = "0.39.6"
22+
dash-network = "0.40.0"
2323
```
2424

2525
### Basic Example

dash-spv-ffi/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dash-spv-ffi"
3-
version = "0.1.0"
3+
version = { workspace = true }
44
edition = "2021"
55
authors = ["Dash Core Developers"]
66
license = "MIT"

dash-spv-ffi/FFI_API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Functions: 25
5959
| `dash_spv_ffi_config_set_persist_mempool` | Sets whether to persist mempool state to disk # Safety - `config` must be a ... | config |
6060
| `dash_spv_ffi_config_set_relay_transactions` | Sets whether to relay transactions (currently a no-op) # Safety - `config` m... | config |
6161
| `dash_spv_ffi_config_set_start_from_height` | Sets the starting block height for synchronization # Safety - `config` must ... | config |
62-
| `dash_spv_ffi_config_set_user_agent` | Sets the user agent string (currently not supported) # Safety - `config` mus... | config |
62+
| `dash_spv_ffi_config_set_user_agent` | Sets the user agent string to advertise in the P2P handshake # Safety - `con... | config |
6363
| `dash_spv_ffi_config_set_validation_mode` | Sets the validation mode for the SPV client # Safety - `config` must be a va... | config |
6464
| `dash_spv_ffi_config_set_wallet_creation_time` | Sets the wallet creation timestamp for synchronization optimization # Safety... | config |
6565
| `dash_spv_ffi_config_testnet` | No description | config |
@@ -555,7 +555,7 @@ dash_spv_ffi_config_set_user_agent(config: *mut FFIClientConfig, user_agent: *co
555555
```
556556

557557
**Description:**
558-
Sets the user agent string (currently not supported) # Safety - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet - `user_agent` must be a valid null-terminated C string - The caller must ensure both pointers remain valid for the duration of this call
558+
Sets the user agent string to advertise in the P2P handshake # Safety - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet - `user_agent` must be a valid null-terminated C string - The caller must ensure both pointers remain valid for the duration of this call
559559

560560
**Safety:**
561561
- `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet - `user_agent` must be a valid null-terminated C string - The caller must ensure both pointers remain valid for the duration of this call

dash-spv-ffi/include/dash_spv_ffi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ int32_t dash_spv_ffi_config_add_peer(FFIClientConfig *config,
518518
const char *addr);
519519

520520
/**
521-
* Sets the user agent string (currently not supported)
521+
* Sets the user agent string to advertise in the P2P handshake
522522
*
523523
* # Safety
524524
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet

dash-spv-ffi/src/config.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ pub unsafe extern "C" fn dash_spv_ffi_config_add_peer(
146146
}
147147
}
148148

149-
/// Sets the user agent string (currently not supported)
149+
/// Sets the user agent string to advertise in the P2P handshake
150150
///
151151
/// # Safety
152152
/// - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
@@ -162,10 +162,11 @@ pub unsafe extern "C" fn dash_spv_ffi_config_set_user_agent(
162162

163163
// Validate the user_agent string
164164
match CStr::from_ptr(user_agent).to_str() {
165-
Ok(_agent_str) => {
166-
// user_agent is not directly settable in current ClientConfig
167-
set_last_error("Setting user agent is not supported in current implementation");
168-
FFIErrorCode::ConfigError as i32
165+
Ok(agent_str) => {
166+
// Store as-is; normalization/length capping is applied at handshake build time
167+
let cfg = &mut (*config).inner;
168+
cfg.user_agent = Some(agent_str.to_string());
169+
FFIErrorCode::Success as i32
169170
}
170171
Err(e) => {
171172
set_last_error(&format!("Invalid UTF-8 in user agent: {}", e));

dash-spv-ffi/tests/test_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ mod tests {
127127

128128
let agent = CString::new("TestAgent/1.0").unwrap();
129129
let result = dash_spv_ffi_config_set_user_agent(config, agent.as_ptr());
130-
assert_eq!(result, FFIErrorCode::ConfigError as i32);
130+
assert_eq!(result, FFIErrorCode::Success as i32);
131131

132132
dash_spv_ffi_config_destroy(config);
133133
}

dash-spv-ffi/tests/unit/test_configuration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ mod tests {
185185
let user_agent = CString::new("TestAgent/1.0").unwrap();
186186
assert_eq!(
187187
dash_spv_ffi_config_set_user_agent(config, user_agent.as_ptr()),
188-
FFIErrorCode::ConfigError as i32
188+
FFIErrorCode::Success as i32
189189
);
190190

191191
assert_eq!(

dash-spv/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "dash-spv"
3-
version = "0.1.0"
3+
version = { workspace = true }
44
edition = "2021"
55
authors = ["Dash Core Team"]
66
description = "Dash SPV (Simplified Payment Verification) client library"

0 commit comments

Comments
 (0)