Function sn_client::broadcast_signed_spends

source ·
pub async fn broadcast_signed_spends(
    from: HotWallet,
    client: &Client,
    signed_spends: BTreeSet<SignedSpend>,
    tx: Transaction,
    change_id: UniquePubkey,
    output_details: BTreeMap<UniquePubkey, CashNoteOutputDetails>,
    verify_store: bool
) -> WalletResult<CashNote>
Expand description

Send tokens to another wallet. Can optionally verify the store has been successful.

Verification will be attempted via GET request through a Spend on the network.

§Arguments

§Return value

WalletResult<CashNote>

§Example

use sn_client::{Client, WalletClient, Error};
use bls::SecretKey;
use sn_transfers::{HotWallet, MainSecretKey};
use std::collections::{BTreeMap, BTreeSet};
use tracing::error;
use sn_transfers::{Transaction, Transfer, UniquePubkey};
let client = Client::new(SecretKey::random(), None, None, None).await?;
let mut wallet = HotWallet::load_from_path(&tmp_path,Some(MainSecretKey::new(SecretKey::random())))?;
let transaction = Transaction {inputs: Vec::new(),outputs: Vec::new(),};
let secret_key = UniquePubkey::new(SecretKey::random().public_key());

println!("Broadcasting the transaction to the network...");
 let cash_note = sn_client::broadcast_signed_spends(
    wallet,
    &client,
    BTreeSet::default(),
    transaction,
    secret_key,
    BTreeMap::new(),
    true
 ).await?;