new checkpoint, add to mempool only if broadcast port from b171d28586

This commit is contained in:
DenioD
2020-08-03 10:49:29 +02:00
parent 21e7e20d6c
commit 7c65e566c4
4 changed files with 121 additions and 73 deletions

View File

@@ -1737,13 +1737,16 @@ impl LightWallet {
Ok(all_txs)
}
pub fn send_to_address(
pub fn send_to_address<F> (
&self,
consensus_branch_id: u32,
spend_params: &[u8],
output_params: &[u8],
tos: Vec<(&str, u64, Option<String>)>
) -> Result<Box<[u8]>, String> {
tos: Vec<(&str, u64, Option<String>)>,
broadcast_fn: F
) -> Result<(String, Vec<u8>), String>
where F: Fn(Box<[u8]>) -> Result<String, String>
{
if !self.unlocked {
return Err("Cannot spend while wallet is locked".to_string());
}
@@ -1958,6 +1961,12 @@ impl LightWallet {
println!("{}: Transaction created", now() - start_time);
println!("Transaction ID: {}", tx.txid());
// Create the TX bytes
let mut raw_tx = vec![];
tx.write(&mut raw_tx).unwrap();
let txid = broadcast_fn(raw_tx.clone().into_boxed_slice())?;
// Mark notes as spent.
{
// Mark sapling notes as unconfirmed spent
@@ -2017,10 +2026,7 @@ impl LightWallet {
}
}
// Return the encoded transaction, so the caller can send it.
let mut raw_tx = vec![];
tx.write(&mut raw_tx).unwrap();
Ok(raw_tx.into_boxed_slice())
Ok((txid, raw_tx))
}
// After some blocks have been mined, we need to remove the Txns from the mempool_tx structure