mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-01-30 18:42:15 +00:00
parent
5675f5b359
commit
5a885adc15
@ -1483,11 +1483,15 @@ impl LightClient {
|
||||
|
||||
info!("Creating transaction");
|
||||
|
||||
let rawtx = self.wallet.write().unwrap().send_to_address(
|
||||
let rawtx = {
|
||||
let _lock = self.sync_lock.lock().unwrap();
|
||||
|
||||
self.wallet.write().unwrap().send_to_address(
|
||||
u32::from_str_radix(&self.config.consensus_branch_id, 16).unwrap(),
|
||||
&self.sapling_spend, &self.sapling_output,
|
||||
addrs
|
||||
);
|
||||
)
|
||||
};
|
||||
|
||||
match rawtx {
|
||||
Ok(txbytes) => broadcast_raw_tx(&self.get_server_uri(), txbytes),
|
||||
|
@ -1946,7 +1946,9 @@ impl LightWallet {
|
||||
// Select notes to cover the target value
|
||||
println!("{}: Selecting notes", now() - start_time);
|
||||
let target_value = Amount::from_u64(total_value).unwrap() + DEFAULT_FEE ;
|
||||
let notes: Vec<_> = self.txs.read().unwrap().iter()
|
||||
|
||||
// Select the candidate notes that are eligible to be spent
|
||||
let mut candidate_notes: Vec<_> = self.txs.read().unwrap().iter()
|
||||
.map(|(txid, tx)| tx.notes.iter().map(move |note| (*txid, note)))
|
||||
.flatten()
|
||||
.filter_map(|(txid, note)| {
|
||||
@ -1960,7 +1962,13 @@ impl LightWallet {
|
||||
.and_then(|zk| zk.extsk.clone());
|
||||
SpendableNote::from(txid, note, anchor_offset, &extsk)
|
||||
}
|
||||
})
|
||||
}).collect();
|
||||
|
||||
// Sort by highest value-notes first.
|
||||
candidate_notes.sort_by(|a, b| b.note.value.cmp(&a.note.value));
|
||||
|
||||
// Select the minimum number of notes required to satisfy the target value
|
||||
let notes: Vec<_> = candidate_notes.iter()
|
||||
.scan(0, |running_total, spendable| {
|
||||
let value = spendable.note.value;
|
||||
let ret = if *running_total < u64::from(target_value) {
|
||||
|
Loading…
Reference in New Issue
Block a user