Struct sn_transfers::HotWallet
source · pub struct HotWallet { /* private fields */ }
Expand description
A hot-wallet.
Implementations§
source§impl HotWallet
impl HotWallet
pub fn api(&self) -> &WalletApi
sourcepub fn lock(&self) -> Result<File>
pub fn lock(&self) -> Result<File>
Locks the wallet and returns exclusive access to the wallet This lock prevents any other process from locking the wallet dir, effectively acts as a mutex for the wallet
sourcepub fn store_cash_notes_to_disk<'a, T>(&self, cash_notes: T) -> Result<()>where
T: IntoIterator<Item = &'a CashNote>,
pub fn store_cash_notes_to_disk<'a, T>(&self, cash_notes: T) -> Result<()>where
T: IntoIterator<Item = &'a CashNote>,
Stores the given cash_notes to the created cash_notes dir
in the wallet dir.
These can then be sent to the recipients out of band, over any channel preferred.
sourcepub fn remove_cash_notes_from_disk<'a, T>(&self, cash_notes: T) -> Result<()>where
T: IntoIterator<Item = &'a UniquePubkey>,
pub fn remove_cash_notes_from_disk<'a, T>(&self, cash_notes: T) -> Result<()>where
T: IntoIterator<Item = &'a UniquePubkey>,
Removes the given cash_notes from the created cash_notes dir
in the wallet dir.
sourcepub fn store_unconfirmed_spend_requests(&mut self) -> Result<()>
pub fn store_unconfirmed_spend_requests(&mut self) -> Result<()>
Store unconfirmed_spend_requests to disk.
sourcepub fn mark_notes_as_spent<'a, T>(&mut self, unique_pubkeys: T)where
T: IntoIterator<Item = &'a UniquePubkey>,
pub fn mark_notes_as_spent<'a, T>(&mut self, unique_pubkeys: T)where
T: IntoIterator<Item = &'a UniquePubkey>,
Remove referenced CashNotes from available_cash_notes
pub fn unconfirmed_spend_requests_exist(&self) -> bool
sourcepub fn try_load_cash_notes(&mut self) -> Result<()>
pub fn try_load_cash_notes(&mut self) -> Result<()>
Try to load any new cash_notes from the cash_notes dir
in the wallet dir.
sourcepub fn load_from_main_key(
root_dir: &Path,
main_key: MainSecretKey
) -> Result<Self>
pub fn load_from_main_key( root_dir: &Path, main_key: MainSecretKey ) -> Result<Self>
Loads a serialized wallet from a path and given main key.
sourcepub fn create_from_key(root_dir: &Path, key: MainSecretKey) -> Result<Self>
pub fn create_from_key(root_dir: &Path, key: MainSecretKey) -> Result<Self>
Creates a serialized wallet for a path and main key. This will overwrite any existing wallet, unlike load_from_main_key
sourcepub fn try_load_from(root_dir: &Path) -> Result<Self>
pub fn try_load_from(root_dir: &Path) -> Result<Self>
Tries to loads a serialized wallet from a path, bailing out if it doesn’t exist.
sourcepub fn load_from_path(
wallet_dir: &Path,
main_key: Option<MainSecretKey>
) -> Result<Self>
pub fn load_from_path( wallet_dir: &Path, main_key: Option<MainSecretKey> ) -> Result<Self>
Loads a serialized wallet from a given path, no additional element will be added to the provided path and strictly taken as the wallet files location.
pub fn address(&self) -> MainPubkey
pub fn unconfirmed_spend_requests(&self) -> &BTreeSet<SignedSpend>
sourcepub fn stash(root_dir: &Path) -> Result<PathBuf>
pub fn stash(root_dir: &Path) -> Result<PathBuf>
Moves all files for the current wallet, including keys and cashnotes to directory root_dir/wallet_ADDRESS
sourcepub fn unstash(root_dir: &Path, addr_hex: &str) -> Result<()>
pub fn unstash(root_dir: &Path, addr_hex: &str) -> Result<()>
Moves a previously stashed wallet to the root wallet directory.
sourcepub fn remove(root_dir: &Path) -> Result<()>
pub fn remove(root_dir: &Path) -> Result<()>
Removes all files for the current wallet, including keys and cashnotes
sourcepub fn clear_specific_spend_request(&mut self, unique_pub_key: UniquePubkey)
pub fn clear_specific_spend_request(&mut self, unique_pub_key: UniquePubkey)
To remove a specific spend from the requests, if eg, we see one spend is bad
sourcepub fn clear_confirmed_spend_requests(&mut self)
pub fn clear_confirmed_spend_requests(&mut self)
Once spends are verified we can clear them and clean up
pub fn balance(&self) -> NanoTokens
pub fn sign( &self, spends: impl IntoIterator<Item = (Spend, DerivationIndex)> ) -> BTreeSet<SignedSpend>
sourcepub fn available_cash_notes(
&mut self
) -> Result<(Vec<(CashNote, Option<DerivedSecretKey>)>, File)>
pub fn available_cash_notes( &mut self ) -> Result<(Vec<(CashNote, Option<DerivedSecretKey>)>, File)>
Returns all available cash_notes and an exclusive access to the wallet so no concurrent processes can get available cash_notes while we’re modifying the wallet once the updated wallet is stored to disk it is safe to drop the WalletExclusiveAccess
sourcepub fn remove_payment_for_xorname(&self, name: &XorName)
pub fn remove_payment_for_xorname(&self, name: &XorName)
Remove the payment_details of the given XorName from disk.
pub fn build_unsigned_transaction( &mut self, to: Vec<(NanoTokens, MainPubkey)>, reason_hash: Option<Hash> ) -> Result<UnsignedTransfer>
sourcepub fn local_send(
&mut self,
to: Vec<(NanoTokens, MainPubkey)>,
reason_hash: Option<Hash>
) -> Result<Vec<CashNote>>
pub fn local_send( &mut self, to: Vec<(NanoTokens, MainPubkey)>, reason_hash: Option<Hash> ) -> Result<Vec<CashNote>>
Make a transfer and return all created cash_notes
sourcepub fn prepare_signed_transfer(
&mut self,
signed_spends: BTreeSet<SignedSpend>,
tx: Transaction,
change_id: UniquePubkey,
output_details: BTreeMap<UniquePubkey, (MainPubkey, DerivationIndex)>
) -> Result<Vec<CashNote>>
pub fn prepare_signed_transfer( &mut self, signed_spends: BTreeSet<SignedSpend>, tx: Transaction, change_id: UniquePubkey, output_details: BTreeMap<UniquePubkey, (MainPubkey, DerivationIndex)> ) -> Result<Vec<CashNote>>
Prepare a signed transaction in local wallet and return all created cash_notes
sourcepub fn local_send_storage_payment(
&mut self,
price_map: &BTreeMap<XorName, (MainPubkey, PaymentQuote, Vec<u8>)>
) -> Result<(NanoTokens, NanoTokens)>
pub fn local_send_storage_payment( &mut self, price_map: &BTreeMap<XorName, (MainPubkey, PaymentQuote, Vec<u8>)> ) -> Result<(NanoTokens, NanoTokens)>
Performs a payment for each content address. Includes payment of network royalties. Returns the amount paid for storage, including the network royalties fee paid.
sourcepub fn deposit(&mut self, received_cash_notes: &Vec<CashNote>) -> Result<()>
pub fn deposit(&mut self, received_cash_notes: &Vec<CashNote>) -> Result<()>
Deposit the given cash_notes on the wallet (without storing them to disk).
sourcepub fn deposit_and_store_to_disk(
&mut self,
received_cash_notes: &Vec<CashNote>
) -> Result<()>
pub fn deposit_and_store_to_disk( &mut self, received_cash_notes: &Vec<CashNote> ) -> Result<()>
Store the given cash_notes to the cash_notes
dir in the wallet dir.
Update and store the updated wallet to disk
This function locks the wallet to prevent concurrent processes from writing to it
pub fn unwrap_transfer( &self, transfer: &Transfer ) -> Result<Vec<CashNoteRedemption>>
pub fn derive_key(&self, derivation_index: &DerivationIndex) -> DerivedSecretKey
Auto Trait Implementations§
impl Freeze for HotWallet
impl RefUnwindSafe for HotWallet
impl Send for HotWallet
impl Sync for HotWallet
impl Unpin for HotWallet
impl UnwindSafe for HotWallet
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FmtForward for T
impl<T> FmtForward for T
source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read moresource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<T> Tap for T
impl<T> Tap for T
source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read moresource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read moresource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read moresource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read moresource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read moresource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.