From 7e6b02c92373c3238470eef1269b3b8237759346 Mon Sep 17 00:00:00 2001 From: Sosthene Date: Fri, 27 Feb 2026 06:27:17 +0100 Subject: [PATCH 1/2] chore: bump spdk-wallet to rm-owned-output branch --- rust/Cargo.lock | 8 ++++---- rust/Cargo.toml | 2 +- rust/src/state/updater.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 242bd474..590ab119 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -120,7 +120,7 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backend-blindbit-v1" version = "0.1.0" -source = "git+https://github.com/cygnet3/spdk?branch=master#ca6fbbeaeeaac756f05fb2ccc5ec3b60d2ceb0ab" +source = "git+https://github.com/cygnet3/spdk?branch=rm-owned-output#c5e5e736b051cea40c5a75c4b7ecbfbfd9b71c98" dependencies = [ "anyhow", "async-trait", @@ -1960,7 +1960,7 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" [[package]] name = "silentpayments" version = "0.5.0" -source = "git+https://github.com/cygnet3/spdk?branch=master#ca6fbbeaeeaac756f05fb2ccc5ec3b60d2ceb0ab" +source = "git+https://github.com/cygnet3/spdk?branch=rm-owned-output#c5e5e736b051cea40c5a75c4b7ecbfbfd9b71c98" dependencies = [ "bech32 0.9.1", "bimap", @@ -2020,7 +2020,7 @@ dependencies = [ [[package]] name = "spdk-core" version = "0.1.0" -source = "git+https://github.com/cygnet3/spdk?branch=master#ca6fbbeaeeaac756f05fb2ccc5ec3b60d2ceb0ab" +source = "git+https://github.com/cygnet3/spdk?branch=rm-owned-output#c5e5e736b051cea40c5a75c4b7ecbfbfd9b71c98" dependencies = [ "anyhow", "async-trait", @@ -2033,7 +2033,7 @@ dependencies = [ [[package]] name = "spdk-wallet" version = "0.1.0" -source = "git+https://github.com/cygnet3/spdk?branch=master#ca6fbbeaeeaac756f05fb2ccc5ec3b60d2ceb0ab" +source = "git+https://github.com/cygnet3/spdk?branch=rm-owned-output#c5e5e736b051cea40c5a75c4b7ecbfbfd9b71c98" dependencies = [ "anyhow", "backend-blindbit-v1", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 898faa77..b7cce8c7 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -8,7 +8,7 @@ crate-type = ["cdylib", "staticlib"] [dependencies] flutter_rust_bridge = "=2.11.1" -spdk-wallet = { git = "https://github.com/cygnet3/spdk", branch = "master" } +spdk-wallet = { git = "https://github.com/cygnet3/spdk", branch = "rm-owned-output" } lazy_static = "1.4" anyhow = "1.0" serde = { version = "1.0.188", features = ["derive"] } diff --git a/rust/src/state/updater.rs b/rust/src/state/updater.rs index afd37609..088fa75b 100644 --- a/rust/src/state/updater.rs +++ b/rust/src/state/updater.rs @@ -6,7 +6,7 @@ use std::{ use spdk_wallet::updater::Updater; use spdk_wallet::{ bitcoin::{absolute::Height, BlockHash, OutPoint}, - updater::SimplifiedOutput, + updater::DiscoveredOutput, }; use crate::stream::{send_scan_progress, send_state_update, ScanProgress, StateUpdate}; @@ -17,7 +17,7 @@ pub struct StateUpdater { update: bool, blkhash: Option, blkheight: Option, - found_outputs: HashMap, + found_outputs: HashMap, found_inputs: HashSet, } @@ -78,7 +78,7 @@ impl Updater for StateUpdater { &mut self, height: Height, blkhash: BlockHash, - found_outputs: HashMap, + found_outputs: HashMap, ) -> Result<()> { // may have already been written by record_block_inputs self.update = true; From abe70e4ce00092811505371c861e0271ff9b7aad Mon Sep 17 00:00:00 2001 From: Sosthene Date: Fri, 27 Feb 2026 14:27:02 +0100 Subject: [PATCH 2/2] refactor: Define `OwnedOutput` locally --- rust/src/api/outputs.rs | 33 +++++++++++++++-- rust/src/api/structs/output_spend_status.rs | 3 +- rust/src/api/structs/owned_output.rs | 40 +++++++++++++++++---- rust/src/api/wallet/transaction.rs | 7 ++-- rust/src/stream.rs | 4 +-- 5 files changed, 72 insertions(+), 15 deletions(-) diff --git a/rust/src/api/outputs.rs b/rust/src/api/outputs.rs index 0a5359d7..d51582e5 100644 --- a/rust/src/api/outputs.rs +++ b/rust/src/api/outputs.rs @@ -6,8 +6,7 @@ use std::{ use flutter_rust_bridge::frb; use serde::{Deserialize, Serialize}; use spdk_wallet::bitcoin::{self, hashes::Hash, hex::DisplayHex}; -use spdk_wallet::bitcoin::{Amount, BlockHash, OutPoint, Txid}; -use spdk_wallet::client::{OutputSpendStatus, OwnedOutput}; +use spdk_wallet::bitcoin::{absolute::Height, Amount, BlockHash, OutPoint, ScriptBuf, Txid}; use anyhow::{Error, Result}; @@ -15,6 +14,34 @@ use crate::api::structs::amount::ApiAmount; use crate::api::structs::owned_output::ApiOwnedOutput; use crate::stream::StateUpdate; +// Local definition of OwnedOutput and OutputSpendStatus. +// These types were removed from spdk-wallet; kept here temporarily +// so that the existing OwnedOutputs serialization/storage code still works. +// TODO: remove when OwnedOutputs is replaced by SQLite storage. + +#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] +pub(crate) enum OutputSpendStatus { + Unspent, + Spent([u8; 32]), + Mined([u8; 32]), +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub(crate) struct OwnedOutput { + pub(crate) blockheight: Height, + pub(crate) tweak: [u8; 32], + pub(crate) amount: Amount, + pub(crate) script: ScriptBuf, + pub(crate) label: Option, + pub(crate) spend_status: OutputSpendStatus, +} + +impl OwnedOutput { + pub fn is_unspent(&self) -> bool { + self.spend_status == OutputSpendStatus::Unspent + } +} + #[frb(opaque)] pub struct OwnedOutPoints(HashSet); @@ -84,7 +111,7 @@ impl OwnedOutputs { tweak: output.tweak.to_be_bytes(), amount: output.value, script: output.script_pubkey.clone(), - label: output.label.clone(), + label: output.label.as_ref().map(|l| l.as_string()), }, ) })) diff --git a/rust/src/api/structs/output_spend_status.rs b/rust/src/api/structs/output_spend_status.rs index 9f1c114b..c0cdfb09 100644 --- a/rust/src/api/structs/output_spend_status.rs +++ b/rust/src/api/structs/output_spend_status.rs @@ -1,6 +1,7 @@ use serde::{Deserialize, Serialize}; use spdk_wallet::bitcoin::hex::{self, DisplayHex}; -use spdk_wallet::client::OutputSpendStatus; + +use crate::api::outputs::OutputSpendStatus; type SpendingTxId = String; type MinedInBlock = String; diff --git a/rust/src/api/structs/owned_output.rs b/rust/src/api/structs/owned_output.rs index 22f9f3fd..6ad39c5e 100644 --- a/rust/src/api/structs/owned_output.rs +++ b/rust/src/api/structs/owned_output.rs @@ -1,9 +1,9 @@ use serde::{Deserialize, Serialize}; -use spdk_wallet::bitcoin::{absolute::Height, ScriptBuf}; -use spdk_wallet::client::OwnedOutput; +use spdk_wallet::bitcoin::{absolute::Height, secp256k1::Scalar, ScriptBuf}; +use spdk_wallet::updater::DiscoveredOutput; -use crate::api::structs::amount::ApiAmount; -use crate::api::structs::output_spend_status::ApiOutputSpendStatus; +use crate::api::outputs::OwnedOutput; +use crate::api::structs::{amount::ApiAmount, output_spend_status::ApiOutputSpendStatus}; #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct ApiOwnedOutput { @@ -15,6 +15,8 @@ pub struct ApiOwnedOutput { pub spend_status: ApiOutputSpendStatus, } +// Conversions to/from local OwnedOutput (for OwnedOutputs serialization) + impl From for ApiOwnedOutput { fn from(value: OwnedOutput) -> Self { ApiOwnedOutput { @@ -22,7 +24,7 @@ impl From for ApiOwnedOutput { tweak: value.tweak, amount: value.amount.into(), script: value.script.to_hex_string(), - label: value.label.map(|l| l.as_string()), + label: value.label, spend_status: value.spend_status.into(), } } @@ -35,8 +37,34 @@ impl From for OwnedOutput { tweak: value.tweak, amount: value.amount.into(), script: ScriptBuf::from_hex(&value.script).unwrap(), - label: value.label.map(|l| l.try_into().unwrap()), + label: value.label, spend_status: value.spend_status.into(), } } } + +// Conversions to/from DiscoveredOutput (for SpClient transaction API) + +impl From for ApiOwnedOutput { + fn from(value: DiscoveredOutput) -> Self { + ApiOwnedOutput { + blockheight: 0, // not available in DiscoveredOutput + tweak: value.tweak.to_be_bytes(), + amount: value.value.into(), + script: value.script_pubkey.to_hex_string(), + label: value.label.map(|l| l.as_string()), + spend_status: ApiOutputSpendStatus::Unspent, + } + } +} + +impl From for DiscoveredOutput { + fn from(value: ApiOwnedOutput) -> Self { + DiscoveredOutput { + tweak: Scalar::from_be_bytes(value.tweak).unwrap(), + value: value.amount.into(), + script_pubkey: ScriptBuf::from_hex(&value.script).unwrap(), + label: value.label.map(|l| l.try_into().unwrap()), + } + } +} diff --git a/rust/src/api/wallet/transaction.rs b/rust/src/api/wallet/transaction.rs index eae70743..55f40ab7 100644 --- a/rust/src/api/wallet/transaction.rs +++ b/rust/src/api/wallet/transaction.rs @@ -9,7 +9,8 @@ use anyhow::Result; use bip39::rand::{thread_rng, RngCore}; use spdk_wallet::backend_blindbit_v1::BlindbitClient; use spdk_wallet::bitcoin::{consensus::serialize, hex::DisplayHex, OutPoint}; -use spdk_wallet::client::{FeeRate, OwnedOutput, Recipient, RecipientAddress, SpClient}; +use spdk_wallet::client::{FeeRate, Recipient, RecipientAddress, SpClient}; +use spdk_wallet::updater::DiscoveredOutput; use super::SpWallet; @@ -23,7 +24,7 @@ impl SpWallet { network: ApiNetwork, ) -> Result { let client = &self.client; - let available_utxos: Result> = api_outputs + let available_utxos: Result> = api_outputs .into_iter() .map(|(string, output)| { let outpoint = OutPoint::from_str(&string)?; @@ -53,7 +54,7 @@ impl SpWallet { network: ApiNetwork, ) -> Result { let client = &self.client; - let available_utxos: Result> = api_outputs + let available_utxos: Result> = api_outputs .into_iter() .map(|(string, output)| { let outpoint = OutPoint::from_str(&string)?; diff --git a/rust/src/stream.rs b/rust/src/stream.rs index 52b81d2d..2b89c975 100644 --- a/rust/src/stream.rs +++ b/rust/src/stream.rs @@ -7,7 +7,7 @@ use crate::frb_generated::StreamSink; use lazy_static::lazy_static; use spdk_wallet::{ bitcoin::{absolute::Height, BlockHash, OutPoint}, - updater::SimplifiedOutput, + updater::DiscoveredOutput, }; lazy_static! { @@ -24,7 +24,7 @@ pub enum StateUpdate { Update { blkheight: Height, blkhash: BlockHash, - found_outputs: HashMap, + found_outputs: HashMap, found_inputs: HashSet, }, }