Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/wallet/src/silentpayments/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
mod keys_file;
mod scanning;
mod wallet;
mod wallet_store;

pub use ::silentpayments::receiving::{Label, Receiver};
pub use ::silentpayments::{Network, SilentPaymentAddress};
pub use keys_file::{SilentPaymentKeysFile, SpendKey};
pub use scanning::{scan_transaction, InputData};
pub use wallet::{Coin, HistoryEntry, SilentPaymentKeys, SpentBy, Wallet};
pub use wallet_store::{WalletPersistenceError, WalletStore, WalletStoreError};

use bitcoin::secp256k1::{self, PublicKey, SecretKey};

Expand Down
2 changes: 1 addition & 1 deletion crates/wallet/src/silentpayments/scanning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub(crate) fn scan_block_inner(
value: out.value,
script_pubkey: out.script_pubkey.clone(),
tweak,
label,
label: label.map(|l| l.into_inner()),
block_height,
spent_by: None,
},
Expand Down
24 changes: 19 additions & 5 deletions crates/wallet/src/silentpayments/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,26 @@ use bitcoin::{hashes::Hash, Amount, OutPoint, ScriptBuf, Txid};
use bitcoinkernel::prelude::{TransactionExt, TxInExt, TxOutPointExt, TxidExt};

use crate::silentpayments::scanning::scan_block_inner;
use crate::silentpayments::{build_receiver, Label, Network, Receiver};
use crate::silentpayments::{build_receiver, Network, Receiver};

#[derive(Debug)]
pub struct SilentPaymentKeys {
pub receiver: Receiver,
pub scan_key: SecretKey,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SpentBy {
pub txid: Txid,
pub block_height: u32,
}

#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Coin {
pub value: Amount,
pub script_pubkey: ScriptBuf,
pub tweak: Scalar,
pub label: Option<Label>,
pub label: Option<Scalar>,
pub block_height: u32,
pub spent_by: Option<SpentBy>,
}
Expand Down Expand Up @@ -82,7 +82,7 @@ pub struct Wallet {
pub keys: Option<SilentPaymentKeys>,
pub spend_key: Option<PublicKey>,
pub network: Network,
utxos: HashMap<OutPoint, Coin>,
pub(crate) utxos: HashMap<OutPoint, Coin>,
}

impl Wallet {
Expand All @@ -96,6 +96,20 @@ impl Wallet {
}
}

pub(crate) fn from_parts(
scan_height: u32,
network: Network,
utxos: HashMap<OutPoint, Coin>,
) -> Self {
Self {
scan_height,
keys: None,
spend_key: None,
network,
utxos,
}
}

pub fn import_keys(
&mut self,
scan_key: SecretKey,
Expand Down
Loading
Loading