mirror of
https://github.com/Qortal/piratewallet-light-cli.git
synced 2025-01-30 18:42:15 +00:00
set fee
This commit is contained in:
parent
b557f144ec
commit
4c39a57ae3
@ -481,8 +481,6 @@ impl Command for SendCommand {
|
||||
|
||||
use std::convert::TryInto;
|
||||
use zcash_primitives::transaction::components::amount::DEFAULT_FEE;
|
||||
let fee: u64 = DEFAULT_FEE.try_into().unwrap();
|
||||
|
||||
|
||||
// Check for a single argument that can be parsed as JSON
|
||||
let arg_list = args[0];
|
||||
@ -495,6 +493,16 @@ impl Command for SendCommand {
|
||||
}
|
||||
};
|
||||
|
||||
//Check for a fee key and convert to u64
|
||||
let fee: u64 = if json_args.has_key("fee") {
|
||||
match json_args["fee"].as_u64() {
|
||||
Some(f) => f.clone(),
|
||||
None => DEFAULT_FEE.try_into().unwrap()
|
||||
}
|
||||
} else {
|
||||
DEFAULT_FEE.try_into().unwrap()
|
||||
};
|
||||
|
||||
//Check for a input key and convert to str
|
||||
let from = if json_args.has_key("input") {
|
||||
json_args["input"].as_str().unwrap().clone()
|
||||
@ -541,7 +549,7 @@ impl Command for SendCommand {
|
||||
Ok(_) => {
|
||||
// Convert to the right format. String -> &str.
|
||||
let tos = send_args.iter().map(|(a, v, m)| (a.as_str(), *v, m.clone()) ).collect::<Vec<_>>();
|
||||
match lightclient.do_send(from, tos) {
|
||||
match lightclient.do_send(from, tos, &fee) {
|
||||
Ok(txid) => { object!{ "txid" => txid } },
|
||||
Err(e) => { object!{ "error" => e } }
|
||||
}.pretty(2)
|
||||
|
@ -1334,7 +1334,7 @@ impl LightClient {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn do_send(&self, from: &str, addrs: Vec<(&str, u64, Option<String>)>) -> Result<String, String> {
|
||||
pub fn do_send(&self, from: &str, addrs: Vec<(&str, u64, Option<String>)>, fee: &u64) -> Result<String, String> {
|
||||
if !self.wallet.read().unwrap().is_unlocked_for_spending() {
|
||||
error!("Wallet is locked");
|
||||
return Err("Wallet is locked".to_string());
|
||||
@ -1345,7 +1345,7 @@ impl LightClient {
|
||||
let rawtx = self.wallet.write().unwrap().send_to_address(
|
||||
u32::from_str_radix(&self.config.consensus_branch_id, 16).unwrap(),
|
||||
&self.sapling_spend, &self.sapling_output,
|
||||
from, addrs
|
||||
from, addrs, fee
|
||||
);
|
||||
|
||||
info!("Transaction Complete");
|
||||
|
@ -36,7 +36,7 @@ use zcash_primitives::{
|
||||
consensus::BranchId,
|
||||
transaction::{
|
||||
builder::{Builder},
|
||||
components::{Amount, OutPoint, TxOut}, components::amount::DEFAULT_FEE,
|
||||
components::{Amount, OutPoint, TxOut}, //components::amount::DEFAULT_FEE,
|
||||
TxId, Transaction,
|
||||
},
|
||||
sapling::Node,
|
||||
@ -1680,7 +1680,8 @@ impl LightWallet {
|
||||
spend_params: &[u8],
|
||||
output_params: &[u8],
|
||||
from: &str,
|
||||
tos: Vec<(&str, u64, Option<String>)>
|
||||
tos: Vec<(&str, u64, Option<String>)>,
|
||||
fee: &u64
|
||||
) -> Result<Box<[u8]>, String> {
|
||||
if !self.unlocked {
|
||||
return Err("Cannot spend while wallet is locked".to_string());
|
||||
@ -1728,7 +1729,7 @@ 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 target_value = Amount::from_u64(total_value).unwrap() + Amount::from_u64(*fee).unwrap() ;
|
||||
let notes: Vec<_> = self.txs.read().unwrap().iter()
|
||||
.map(|(txid, tx)| tx.notes.iter().map(move |note| (*txid, note)))
|
||||
.flatten()
|
||||
@ -1750,6 +1751,9 @@ impl LightWallet {
|
||||
|
||||
let mut builder = Builder::new(height);
|
||||
|
||||
//set fre
|
||||
builder.set_fee(Amount::from_u64(*fee).unwrap());
|
||||
|
||||
// A note on t addresses
|
||||
// Funds received by t-addresses can't be explicitly spent in ZecWallet.
|
||||
// ZecWallet will lazily consolidate all t address funds into your shielded addresses.
|
||||
|
@ -82,7 +82,7 @@ impl BugBip39Derivation {
|
||||
let txid = if amount > 0 {
|
||||
println!("Sending funds to ourself.");
|
||||
let fee: u64 = DEFAULT_FEE.try_into().unwrap();
|
||||
match client.do_send(client.do_address()["z_addresses"][0].as_str().unwrap(), vec![(&zaddr, amount-fee, None)]) {
|
||||
match client.do_send(client.do_address()["z_addresses"][0].as_str().unwrap(), vec![(&zaddr, amount-fee, None)], &fee) {
|
||||
Ok(txid) => txid,
|
||||
Err(e) => {
|
||||
let r = object!{
|
||||
|
Loading…
Reference in New Issue
Block a user