bsv-sdk 0.2.81

Pure Rust implementation of the BSV Blockchain SDK
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
//! Core types for the remittance protocol.
//!
//! Defines enums, type aliases, state transitions, the LoggerLike trait,
//! and all protocol structs (Unit, Amount, Invoice, Settlement, etc.)
//! with serde annotations for wire-format parity with the TypeScript SDK.

use std::collections::HashMap;
use std::sync::Arc;

/// Unique identifier for a remittance thread.
pub type ThreadId = String;

/// Unique identifier for a remittance option within an invoice.
pub type RemittanceOptionId = String;

/// Unix timestamp in milliseconds.
pub type UnixMillis = u64;

/// The state of a remittance thread in the protocol state machine.
///
/// Each variant maps to the exact wire string used by the TypeScript SDK.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
pub enum RemittanceThreadState {
    #[cfg_attr(feature = "network", serde(rename = "new"))]
    New,
    #[cfg_attr(feature = "network", serde(rename = "identityRequested"))]
    IdentityRequested,
    #[cfg_attr(feature = "network", serde(rename = "identityResponded"))]
    IdentityResponded,
    #[cfg_attr(feature = "network", serde(rename = "identityAcknowledged"))]
    IdentityAcknowledged,
    #[cfg_attr(feature = "network", serde(rename = "invoiced"))]
    Invoiced,
    #[cfg_attr(feature = "network", serde(rename = "settled"))]
    Settled,
    #[cfg_attr(feature = "network", serde(rename = "receipted"))]
    Receipted,
    #[cfg_attr(feature = "network", serde(rename = "terminated"))]
    Terminated,
    #[cfg_attr(feature = "network", serde(rename = "errored"))]
    Errored,
}

impl std::fmt::Display for RemittanceThreadState {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let s = match self {
            Self::New => "new",
            Self::IdentityRequested => "identityRequested",
            Self::IdentityResponded => "identityResponded",
            Self::IdentityAcknowledged => "identityAcknowledged",
            Self::Invoiced => "invoiced",
            Self::Settled => "settled",
            Self::Receipted => "receipted",
            Self::Terminated => "terminated",
            Self::Errored => "errored",
        };
        f.write_str(s)
    }
}

/// The kind of message in the remittance protocol.
///
/// Each variant maps to the exact wire string used by the TypeScript SDK.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
pub enum RemittanceKind {
    #[cfg_attr(feature = "network", serde(rename = "invoice"))]
    Invoice,
    #[cfg_attr(feature = "network", serde(rename = "identityVerificationRequest"))]
    IdentityVerificationRequest,
    #[cfg_attr(feature = "network", serde(rename = "identityVerificationResponse"))]
    IdentityVerificationResponse,
    #[cfg_attr(
        feature = "network",
        serde(rename = "identityVerificationAcknowledgment")
    )]
    IdentityVerificationAcknowledgment,
    #[cfg_attr(feature = "network", serde(rename = "settlement"))]
    Settlement,
    #[cfg_attr(feature = "network", serde(rename = "receipt"))]
    Receipt,
    #[cfg_attr(feature = "network", serde(rename = "termination"))]
    Termination,
}

impl std::fmt::Display for RemittanceKind {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let s = match self {
            Self::Invoice => "invoice",
            Self::IdentityVerificationRequest => "identityVerificationRequest",
            Self::IdentityVerificationResponse => "identityVerificationResponse",
            Self::IdentityVerificationAcknowledgment => "identityVerificationAcknowledgment",
            Self::Settlement => "settlement",
            Self::Receipt => "receipt",
            Self::Termination => "termination",
        };
        f.write_str(s)
    }
}

/// Returns the valid successor states for a given remittance thread state.
///
/// The transition table matches the TypeScript SDK's `REMITTANCE_STATE_TRANSITIONS`.
/// Notably, `Invoiced` allows back-transitions to identity states.
pub fn allowed_transitions(state: &RemittanceThreadState) -> &'static [RemittanceThreadState] {
    use RemittanceThreadState::*;
    match state {
        New => &[IdentityRequested, Invoiced, Settled, Terminated, Errored],
        IdentityRequested => &[
            IdentityResponded,
            IdentityAcknowledged,
            Invoiced,
            Settled,
            Terminated,
            Errored,
        ],
        IdentityResponded => &[IdentityAcknowledged, Invoiced, Settled, Terminated, Errored],
        IdentityAcknowledged => &[Invoiced, Settled, Terminated, Errored],
        Invoiced => &[
            IdentityRequested,
            IdentityResponded,
            IdentityAcknowledged,
            Settled,
            Terminated,
            Errored,
        ],
        Settled => &[Receipted, Terminated, Errored],
        Receipted => &[Terminated, Errored],
        Terminated => &[Errored],
        Errored => &[],
    }
}

/// Returns `true` if transitioning from `from` to `to` is valid per the protocol.
pub fn is_valid_transition(from: &RemittanceThreadState, to: &RemittanceThreadState) -> bool {
    allowed_transitions(from).contains(to)
}

/// Trait for pluggable logging, matching the TypeScript SDK's `LoggerLike` interface.
///
/// Implementors must be `Send + Sync` for use in async contexts.
pub trait LoggerLike: Send + Sync {
    /// Log an informational message.
    fn log(&self, args: &[&dyn std::fmt::Debug]);
    /// Log a warning message.
    fn warn(&self, args: &[&dyn std::fmt::Debug]);
    /// Log an error message.
    fn error(&self, args: &[&dyn std::fmt::Debug]);
}

// ---------------------------------------------------------------------------
// Protocol Structs
// ---------------------------------------------------------------------------

/// A currency unit with namespace, code, and optional decimal places.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct Unit {
    pub namespace: String,
    pub code: String,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub decimals: Option<u32>,
}

/// Returns the standard BSV satoshi unit.
pub fn sat_unit() -> Unit {
    Unit {
        namespace: "bsv".into(),
        code: "sat".into(),
        decimals: Some(0),
    }
}

/// A monetary amount as a decimal string with an associated unit.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct Amount {
    pub value: String,
    pub unit: Unit,
}

/// A single line item in an invoice.
#[derive(Clone, Debug, PartialEq)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct LineItem {
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub id: Option<String>,
    pub description: String,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub quantity: Option<String>,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub unit_price: Option<Amount>,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub amount: Option<Amount>,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub metadata: Option<HashMap<String, serde_json::Value>>,
}

/// Common fields shared by all instrument-type messages (e.g., Invoice).
///
/// Flattened into the parent struct via `#[serde(flatten)]` so that these
/// fields appear at the top level in JSON, matching the TypeScript SDK wire format.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct InstrumentBase {
    pub thread_id: String,
    pub payee: String,
    pub payer: String,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub note: Option<String>,
    pub line_items: Vec<LineItem>,
    pub total: Amount,
    pub invoice_number: String,
    pub created_at: u64,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub arbitrary: Option<HashMap<String, serde_json::Value>>,
}

/// An invoice message in the remittance protocol.
///
/// The `base` field is flattened so InstrumentBase fields appear at the
/// top level in JSON, alongside `kind`, `expiresAt`, and `options`.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct Invoice {
    pub kind: RemittanceKind,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub expires_at: Option<u64>,
    pub options: HashMap<String, serde_json::Value>,
    #[cfg_attr(feature = "network", serde(flatten))]
    pub base: InstrumentBase,
}

/// Sub-struct describing the identity verification request parameters.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct IdentityRequest {
    pub types: HashMap<String, Vec<String>>,
    pub certifiers: Vec<String>,
}

/// A request for identity verification from a peer.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct IdentityVerificationRequest {
    pub kind: RemittanceKind,
    pub thread_id: String,
    pub request: IdentityRequest,
}

/// A certificate proving identity in the remittance wire protocol.
///
/// Named `RemittanceCertificate` to avoid collision with
/// `crate::wallet::interfaces::IdentityCertificate` which has a different
/// structure (strongly-typed `PublicKey`, `CertificateType`, etc.).
/// This struct uses plain strings for all fields to match the TypeScript
/// SDK wire format exactly.
///
/// The `cert_type` field is renamed to `"type"` in JSON to avoid the
/// Rust reserved keyword while maintaining wire-format compatibility.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct RemittanceCertificate {
    #[cfg_attr(feature = "network", serde(rename = "type"))]
    pub cert_type: String,
    pub certifier: String,
    pub subject: String,
    pub fields: HashMap<String, String>,
    pub signature: String,
    pub serial_number: String,
    pub revocation_outpoint: String,
    pub keyring_for_verifier: HashMap<String, String>,
}

/// A response containing identity certificates.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct IdentityVerificationResponse {
    pub kind: RemittanceKind,
    pub thread_id: String,
    pub certificates: Vec<RemittanceCertificate>,
}

/// Acknowledgment that identity verification was received.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct IdentityVerificationAcknowledgment {
    pub kind: RemittanceKind,
    pub thread_id: String,
}

/// A settlement message indicating payment has been made.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct Settlement {
    pub kind: RemittanceKind,
    pub thread_id: String,
    pub module_id: String,
    pub option_id: String,
    pub sender: String,
    pub created_at: u64,
    pub artifact: serde_json::Value,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub note: Option<String>,
}

/// A receipt confirming payment was received and verified.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct Receipt {
    pub kind: RemittanceKind,
    pub thread_id: String,
    pub module_id: String,
    pub option_id: String,
    pub payee: String,
    pub payer: String,
    pub created_at: u64,
    pub receipt_data: serde_json::Value,
}

/// A termination message ending the remittance thread.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct Termination {
    pub code: String,
    pub message: String,
    #[cfg_attr(feature = "network", serde(skip_serializing_if = "Option::is_none"))]
    pub details: Option<serde_json::Value>,
}

/// A peer-to-peer message envelope used for transport.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct PeerMessage {
    pub message_id: String,
    pub sender: String,
    pub recipient: String,
    pub message_box: String,
    pub body: String,
}

/// The outer envelope wrapping all remittance protocol messages.
///
/// The `v` field is a u8 (integer 1 in JSON, not a string).
/// The `payload` field accepts arbitrary JSON for flexibility.
#[derive(Clone, Debug)]
#[cfg_attr(feature = "network", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "network", serde(rename_all = "camelCase"))]
pub struct RemittanceEnvelope {
    pub v: u8,
    pub id: String,
    pub kind: RemittanceKind,
    pub thread_id: String,
    pub created_at: u64,
    pub payload: serde_json::Value,
}

/// Runtime context passed to remittance modules during execution.
///
/// Never serialized -- holds Arc references to runtime services.
/// Does not derive serde traits.
#[derive(Clone)]
pub struct ModuleContext {
    pub wallet: Arc<dyn crate::wallet::interfaces::WalletInterface>,
    pub originator: Option<String>,
    pub now: Arc<dyn Fn() -> u64 + Send + Sync>,
    pub logger: Option<Arc<dyn LoggerLike>>,
}

#[cfg(test)]
mod tests {
    use super::*;

    // -----------------------------------------------------------------------
    // Serialization tests (require "network" feature via dev-dependencies)
    // -----------------------------------------------------------------------

    #[test]
    fn test_thread_state_serialization() {
        use RemittanceThreadState::*;
        let cases = vec![
            (New, r#""new""#),
            (IdentityRequested, r#""identityRequested""#),
            (IdentityResponded, r#""identityResponded""#),
            (IdentityAcknowledged, r#""identityAcknowledged""#),
            (Invoiced, r#""invoiced""#),
            (Settled, r#""settled""#),
            (Receipted, r#""receipted""#),
            (Terminated, r#""terminated""#),
            (Errored, r#""errored""#),
        ];
        for (variant, expected) in cases {
            let json = serde_json::to_string(&variant).unwrap();
            assert_eq!(json, expected, "serialization mismatch for {:?}", variant);
        }
    }

    #[test]
    fn test_thread_state_deserialization() {
        use RemittanceThreadState::*;
        let cases = vec![
            (r#""new""#, New),
            (r#""identityRequested""#, IdentityRequested),
            (r#""identityResponded""#, IdentityResponded),
            (r#""identityAcknowledged""#, IdentityAcknowledged),
            (r#""invoiced""#, Invoiced),
            (r#""settled""#, Settled),
            (r#""receipted""#, Receipted),
            (r#""terminated""#, Terminated),
            (r#""errored""#, Errored),
        ];
        for (json, expected) in cases {
            let parsed: RemittanceThreadState = serde_json::from_str(json).unwrap();
            assert_eq!(parsed, expected, "deserialization mismatch for {}", json);
        }
    }

    #[test]
    fn test_kind_serialization() {
        use RemittanceKind::*;
        let cases = vec![
            (Invoice, r#""invoice""#),
            (
                IdentityVerificationRequest,
                r#""identityVerificationRequest""#,
            ),
            (
                IdentityVerificationResponse,
                r#""identityVerificationResponse""#,
            ),
            (
                IdentityVerificationAcknowledgment,
                r#""identityVerificationAcknowledgment""#,
            ),
            (Settlement, r#""settlement""#),
            (Receipt, r#""receipt""#),
            (Termination, r#""termination""#),
        ];
        for (variant, expected) in cases {
            let json = serde_json::to_string(&variant).unwrap();
            assert_eq!(json, expected, "serialization mismatch for {:?}", variant);
        }
    }

    #[test]
    fn test_kind_deserialization() {
        use RemittanceKind::*;
        let cases = vec![
            (r#""invoice""#, Invoice),
            (
                r#""identityVerificationRequest""#,
                IdentityVerificationRequest,
            ),
            (
                r#""identityVerificationResponse""#,
                IdentityVerificationResponse,
            ),
            (
                r#""identityVerificationAcknowledgment""#,
                IdentityVerificationAcknowledgment,
            ),
            (r#""settlement""#, Settlement),
            (r#""receipt""#, Receipt),
            (r#""termination""#, Termination),
        ];
        for (json, expected) in cases {
            let parsed: RemittanceKind = serde_json::from_str(json).unwrap();
            assert_eq!(parsed, expected, "deserialization mismatch for {}", json);
        }
    }

    // -----------------------------------------------------------------------
    // State transition tests
    // -----------------------------------------------------------------------

    #[test]
    fn test_valid_transitions() {
        use RemittanceThreadState::*;

        // New can go to several states
        assert!(is_valid_transition(&New, &IdentityRequested));
        assert!(is_valid_transition(&New, &Invoiced));
        assert!(is_valid_transition(&New, &Settled));
        assert!(is_valid_transition(&New, &Terminated));
        assert!(is_valid_transition(&New, &Errored));

        // IdentityRequested
        assert!(is_valid_transition(&IdentityRequested, &IdentityResponded));
        assert!(is_valid_transition(&IdentityRequested, &Invoiced));

        // IdentityResponded
        assert!(is_valid_transition(
            &IdentityResponded,
            &IdentityAcknowledged
        ));
        assert!(is_valid_transition(&IdentityResponded, &Invoiced));

        // IdentityAcknowledged
        assert!(is_valid_transition(&IdentityAcknowledged, &Invoiced));
        assert!(is_valid_transition(&IdentityAcknowledged, &Settled));

        // Settled
        assert!(is_valid_transition(&Settled, &Receipted));
        assert!(is_valid_transition(&Settled, &Terminated));

        // Receipted
        assert!(is_valid_transition(&Receipted, &Terminated));
        assert!(is_valid_transition(&Receipted, &Errored));

        // Terminated
        assert!(is_valid_transition(&Terminated, &Errored));
    }

    #[test]
    fn test_invalid_transitions() {
        use RemittanceThreadState::*;

        assert!(!is_valid_transition(&Receipted, &New));
        assert!(!is_valid_transition(&Errored, &New));
        assert!(!is_valid_transition(&Errored, &Settled));
        assert!(!is_valid_transition(&New, &Receipted));
        assert!(!is_valid_transition(&Settled, &Invoiced));
        assert!(!is_valid_transition(&Terminated, &Settled));
    }

    #[test]
    fn test_invoiced_back_transitions() {
        use RemittanceThreadState::*;

        // Invoiced can transition back to identity states
        assert!(is_valid_transition(&Invoiced, &IdentityRequested));
        assert!(is_valid_transition(&Invoiced, &IdentityResponded));
        assert!(is_valid_transition(&Invoiced, &IdentityAcknowledged));
    }

    #[test]
    fn test_errored_is_terminal() {
        let transitions = allowed_transitions(&RemittanceThreadState::Errored);
        assert!(
            transitions.is_empty(),
            "Errored should be a terminal state with no transitions"
        );
    }

    #[test]
    fn test_logger_like_is_object_safe() {
        struct TestLogger;

        impl LoggerLike for TestLogger {
            fn log(&self, args: &[&dyn std::fmt::Debug]) {
                let _ = args;
            }
            fn warn(&self, args: &[&dyn std::fmt::Debug]) {
                let _ = args;
            }
            fn error(&self, args: &[&dyn std::fmt::Debug]) {
                let _ = args;
            }
        }

        let logger = TestLogger;
        let dyn_logger: &dyn LoggerLike = &logger;
        dyn_logger.log(&[&"test message"]);
        dyn_logger.warn(&[&"warning"]);
        dyn_logger.error(&[&"error"]);
    }

    #[test]
    fn test_thread_state_display() {
        assert_eq!(RemittanceThreadState::New.to_string(), "new");
        assert_eq!(
            RemittanceThreadState::IdentityRequested.to_string(),
            "identityRequested"
        );
        assert_eq!(RemittanceThreadState::Invoiced.to_string(), "invoiced");
        assert_eq!(RemittanceThreadState::Errored.to_string(), "errored");
    }

    // Wire-format roundtrip tests for Plan 01-02 structs are in
    // tests/remittance_wire_format.rs (integration test file) to avoid
    // pre-existing wallet module compilation errors in lib test target.
}