mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-07-30 03:41:28 +00:00
Use remote server's latest height when building redeem P2SH transactions, as our latest height may not be correct.
This commit is contained in:
@@ -9,6 +9,7 @@ use std::path::{Path, PathBuf};
|
|||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::collections::{HashMap};
|
use std::collections::{HashMap};
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
use std::convert::TryFrom;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::prelude::*;
|
use std::io::prelude::*;
|
||||||
use std::io::{BufReader, Error, ErrorKind};
|
use std::io::{BufReader, Error, ErrorKind};
|
||||||
@@ -1753,10 +1754,14 @@ impl LightClient {
|
|||||||
let result = {
|
let result = {
|
||||||
let _lock = self.sync_lock.lock().unwrap();
|
let _lock = self.sync_lock.lock().unwrap();
|
||||||
|
|
||||||
|
// This will hold the latest block fetched from the RPC
|
||||||
|
let latest_block_height = fetch_latest_block(&self.get_server_uri())?.height;
|
||||||
|
let latest_block_height_u32 = u32::try_from(latest_block_height).unwrap();
|
||||||
|
|
||||||
self.wallet.write().unwrap().redeem_p2sh(
|
self.wallet.write().unwrap().redeem_p2sh(
|
||||||
u32::from_str_radix(&self.config.consensus_branch_id, 16).unwrap(),
|
u32::from_str_radix(&self.config.consensus_branch_id, 16).unwrap(),
|
||||||
&self.sapling_spend, &self.sapling_output,
|
&self.sapling_spend, &self.sapling_output,
|
||||||
from, addrs, script, txid, lock_time, secret, privkey, fee,
|
from, addrs, script, txid, lock_time, secret, privkey, fee, latest_block_height_u32,
|
||||||
|txbytes| broadcast_raw_tx(&self.get_server_uri(), txbytes)
|
|txbytes| broadcast_raw_tx(&self.get_server_uri(), txbytes)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
@@ -2787,6 +2787,7 @@ impl LightWallet {
|
|||||||
secret: &[u8],
|
secret: &[u8],
|
||||||
privkey: &[u8],
|
privkey: &[u8],
|
||||||
fee: &u64,
|
fee: &u64,
|
||||||
|
chain_height: u32,
|
||||||
broadcast_fn: F
|
broadcast_fn: F
|
||||||
) -> Result<(String, Vec<u8>), String>
|
) -> Result<(String, Vec<u8>), String>
|
||||||
where F: Fn(Box<[u8]>) -> Result<String, String>
|
where F: Fn(Box<[u8]>) -> Result<String, String>
|
||||||
@@ -2878,7 +2879,9 @@ impl LightWallet {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let mut builder = Builder::new(height);
|
// Use passed-in chain_height as the chain's latest height, as we may not have
|
||||||
|
// a full sync locally
|
||||||
|
let mut builder = Builder::new(chain_height);
|
||||||
|
|
||||||
//set fre
|
//set fre
|
||||||
builder.set_fee(Amount::from_u64(*fee).unwrap());
|
builder.set_fee(Amount::from_u64(*fee).unwrap());
|
||||||
|
Reference in New Issue
Block a user