Skip to content
Merged
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/rs-platform-wallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ tracing = "0.1"
# Encoding
hex = "0.4"
bs58 = "0.5"
serde = { version = "1", default-features = false, features = ["derive"], optional = true }
serde_json = "1.0"

# Image processing (DIP-15 avatar hash + fingerprint)
Expand Down Expand Up @@ -69,6 +70,14 @@ default = ["bls", "eddsa"]
bls = ["key-wallet/bls", "key-wallet-manager/bls"]
eddsa = ["key-wallet/eddsa", "key-wallet-manager/eddsa"]
shielded = ["dep:grovedb-commitment-tree", "dep:zip32", "dash-sdk/shielded", "dpp/shielded-client"]
# Opt-in serde derives on the changeset types. Activates `key-wallet/serde`,
# `key-wallet-manager/serde`, and `dash-sdk/serde`. `dpp` derives serde unconditionally.
serde = [
"dep:serde",
"key-wallet/serde",
"key-wallet-manager/serde",
"dash-sdk/serde",
Comment thread
lklimek marked this conversation as resolved.
]
# Forward to the upstream `key-wallet` / `key-wallet-manager`
# `keep-finalized-transactions` feature. With it OFF (the default),
# chainlocked transactions are evicted from the in-memory
Expand Down
19 changes: 19 additions & 0 deletions packages/rs-platform-wallet/src/changeset/changeset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ use crate::wallet::identity::{ContactRequest, DashPayProfile, EstablishedContact
/// upstream type. Tests that need to inspect a changeset's contents
/// reach into individual fields directly.
#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CoreChangeSet {
/// Transaction records produced by this batch.
///
Expand Down Expand Up @@ -257,6 +258,7 @@ impl Merge for CoreChangeSet {
/// call [`IdentityEntry::from_managed`] to produce a fresh scalar
/// snapshot so the merge can resolve the latest state by last-write-wins.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct IdentityEntry {
/// Identity identifier.
pub id: Identifier,
Expand Down Expand Up @@ -331,6 +333,7 @@ impl IdentityEntry {
/// path — platform-wallet itself never carries or persists the key
/// bytes.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct IdentityKeyDerivationIndices {
/// DIP-9 identity index (hardened).
pub identity_index: u32,
Expand All @@ -351,6 +354,7 @@ pub struct IdentityKeyDerivationIndices {
/// persist it. When either is `None` the key is watch-only from
/// this wallet's point of view.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct IdentityKeyEntry {
/// Owning identity.
pub identity_id: Identifier,
Expand Down Expand Up @@ -379,6 +383,7 @@ pub struct IdentityKeyEntry {
/// `{upsert, remove}` per key per mutation — the merge does not resolve
/// insert-vs-tombstone for the same key.
#[derive(Debug, Clone, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct IdentityKeysChangeSet {
/// Inserted or updated identity keys keyed by (identity_id, key_id).
pub upserts: BTreeMap<(Identifier, KeyID), IdentityKeyEntry>,
Expand Down Expand Up @@ -415,6 +420,7 @@ impl Merge for IdentityKeysChangeSet {
/// [`ContactChangeSet`]; same mitigation: every current emitter
/// produces only one of {insert, tombstone} per key per mutation.
#[derive(Debug, Clone, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct IdentityChangeSet {
/// Inserted or updated identities keyed by identifier.
pub identities: BTreeMap<Identifier, IdentityEntry>,
Expand Down Expand Up @@ -500,6 +506,7 @@ impl Merge for IdentityChangeSet {
///
/// Modelled after [`crate::wallet::identity::ContactRequest`].
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ContactRequestEntry {
/// The contact request.
pub request: ContactRequest,
Expand All @@ -508,6 +515,7 @@ pub struct ContactRequestEntry {
/// Key for sent contact requests: the **owner** sent a request TO the
/// **recipient**. Used for `sent_requests` and `removed_sent`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SentContactRequestKey {
/// The identity owned by this wallet (the sender).
pub owner_id: Identifier,
Expand All @@ -519,6 +527,7 @@ pub struct SentContactRequestKey {
/// FROM the **sender**. Used for `incoming_requests` and
/// `removed_incoming`.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ReceivedContactRequestKey {
/// The identity owned by this wallet (the recipient).
pub owner_id: Identifier,
Expand Down Expand Up @@ -567,6 +576,7 @@ pub struct ReceivedContactRequestKey {
/// semantics, the merge impl should resolve `sent_requests ∩
/// removed_sent` by last-seen rather than carrying both.
#[derive(Debug, Clone, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ContactChangeSet {
/// Sent contact requests keyed by (owner → recipient).
pub sent_requests: BTreeMap<SentContactRequestKey, ContactRequestEntry>,
Expand Down Expand Up @@ -629,6 +639,7 @@ impl Merge for ContactChangeSet {
/// persisters can apply the entry without guessing which account or
/// HD slot it belongs to.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PlatformAddressBalanceEntry {
pub wallet_id: WalletId,
pub account_index: u32,
Expand All @@ -638,6 +649,7 @@ pub struct PlatformAddressBalanceEntry {
}

#[derive(Debug, Clone, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PlatformAddressChangeSet {
/// Updated platform addresses produced by the last sync pass.
/// A `Vec` rather than a map because the diff already deduplicates
Expand Down Expand Up @@ -694,6 +706,7 @@ impl Merge for PlatformAddressChangeSet {

/// Changes to the asset lock store.
#[derive(Debug, Clone, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AssetLockChangeSet {
/// Asset lock entries keyed by outpoint (txid + output index).
///
Expand All @@ -710,6 +723,7 @@ pub struct AssetLockChangeSet {
/// Contains all fields needed to fully reconstruct a
/// [`TrackedAssetLock`](crate::wallet::asset_lock::tracked::TrackedAssetLock).
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AssetLockEntry {
/// The outpoint identifying this credit output (txid + vout).
pub out_point: OutPoint,
Expand Down Expand Up @@ -752,6 +766,7 @@ impl Merge for AssetLockChangeSet {
/// purely in the manager's in-memory cache. Persistence carries only
/// the post-sync balance updates and tombstones.
#[derive(Debug, Clone, Default, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TokenBalanceChangeSet {
/// Updated token balances keyed by `(identity_id, token_id)`.
/// Last write wins on merge.
Expand Down Expand Up @@ -792,6 +807,7 @@ impl Merge for TokenBalanceChangeSet {
/// time; the parent `Option<...>` field stays `None` for every other
/// flush.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct WalletMetadataEntry {
/// Network the wallet is bound to.
pub network: Network,
Expand All @@ -816,6 +832,7 @@ pub struct WalletMetadataEntry {
/// is simple `extend` and dedup is the apply-side caller's
/// responsibility if it ever matters.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AccountRegistrationEntry {
/// The account variant being registered.
pub account_type: AccountType,
Expand Down Expand Up @@ -849,6 +866,7 @@ pub struct AccountRegistrationEntry {
/// the upstream type. Tests that need to inspect snapshot contents
/// reach into the `addresses` vec by index instead.
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AccountAddressPoolEntry {
/// Which account this pool belongs to.
pub account_type: AccountType,
Expand Down Expand Up @@ -876,6 +894,7 @@ pub struct AccountAddressPoolEntry {
/// Not `PartialEq` because [`CoreChangeSet`] isn't (its `records` carry
/// `TransactionRecord`, which is `Debug + Clone` only upstream).
#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
Comment thread
coderabbitai[bot] marked this conversation as resolved.
pub struct PlatformWalletChangeSet {
/// Core-wallet deltas projected from upstream `WalletEvent`s:
/// transaction records, UTXO add/remove, height checkpoints, IS-lock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use crate::wallet::shielded::{ShieldedNote, SubwalletId};

/// Aggregated delta of shielded state for one persister flush.
#[derive(Debug, Clone, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShieldedChangeSet {
/// Notes discovered (or re-saved with updated state) per
/// subwallet. Keyed by `(wallet_id, account_index)`. Order
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::changeset::AssetLockEntry;
/// Marking the enum `#[non_exhaustive]` would force wildcard arms
/// and silently lose that signal.
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum AssetLockStatus {
Built,
Broadcast,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use dpp::prelude::{BlockHeight, CoreBlockHeight, TimestampMillis};

/// Block time information containing height, core height, and timestamp
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct BlockTime {
/// Platform block height
pub height: BlockHeight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use dpp::prelude::{CoreBlockHeight, Identifier};

/// A contact request represents a one-way relationship between two identities
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ContactRequest {
/// The unique id of the sender (owner of the contact request)
pub sender_id: Identifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use dpp::prelude::Identifier;
///
/// This is formed when both identities have sent contact requests to each other.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct EstablishedContact {
/// The contact's identity unique identifier
pub contact_identity_id: Identifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use dpp::prelude::Identifier;

/// Direction of a DashPay payment, from the owner's point of view.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum PaymentDirection {
/// The owner sent this payment to the counterparty.
Sent,
Expand All @@ -28,6 +29,7 @@ pub enum PaymentDirection {

/// Status of a DashPay payment on Core chain.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum PaymentStatus {
/// Broadcast but not yet confirmed.
#[default]
Expand Down Expand Up @@ -63,6 +65,7 @@ pub struct DashpayAddressMatch {
/// Keyed by transaction id (hex string, matching evo-tool's
/// `dashpay_payments.tx_id` column which is `TEXT UNIQUE NOT NULL`).
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PaymentEntry {
/// The other identity in this payment. Whether they're the
/// sender or receiver is encoded in `direction`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use sha2::{Digest, Sha256};
/// User-facing DashPay profile data published via the DashPay data
/// contract. This is the **output/stored** model — no raw image bytes.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DashPayProfile {
/// Display name (publicly visible, max 25 chars per DIP-15).
pub display_name: Option<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub enum PrivateKeyData {

/// Identity lifecycle status on Platform.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum IdentityStatus {
#[default]
Unknown,
Expand All @@ -38,6 +39,7 @@ pub enum IdentityStatus {

/// DPNS username associated with an identity.
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DpnsNameInfo {
pub label: String,
pub acquired_at: Option<u64>,
Expand Down
2 changes: 2 additions & 0 deletions packages/rs-platform-wallet/src/wallet/shielded/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use crate::wallet::platform_wallet::WalletId;
/// sync watermarks inside a [`ShieldedStore`] so a single store
/// can hold state for many wallets/accounts without leakage.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SubwalletId {
/// 32-byte wallet identifier (matches `PlatformWallet::wallet_id`).
pub wallet_id: [u8; 32],
Expand All @@ -58,6 +59,7 @@ impl SubwalletId {
/// `orchard::Note` is in `note_data` as 115 bytes
/// (`recipient(43) || value(8 LE) || rho(32) || rseed(32)`).
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ShieldedNote {
/// Global position in the commitment tree.
pub position: u64,
Expand Down
1 change: 1 addition & 0 deletions packages/rs-sdk/src/platform/address_sync/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub type LeafBoundaryKey = Vec<u8>;

/// Funds stored for a platform address.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct AddressFunds {
/// Address nonce used for anti-replay.
pub nonce: AddressNonce,
Expand Down
Loading