diff --git a/lib/Cargo.toml b/lib/Cargo.toml index aa5c4bf..9aa1859 100644 --- a/lib/Cargo.toml +++ b/lib/Cargo.toml @@ -48,33 +48,33 @@ reqwest = { version = "0.10.8", features = ["blocking", "json"] } [dependencies.bellman] git = "https://github.com/CalDescent1/librustzcash.git" -rev = "1a8686863b10a608ececdede3deb82d2fb4218fa" +rev = "9eeaf4f0269bf3936b2d57a67d7c6ba85bb8e6e9" default-features = false features = ["groth16", "multicore"] [dependencies.pairing] git = "https://github.com/CalDescent1/librustzcash.git" -rev = "1a8686863b10a608ececdede3deb82d2fb4218fa" +rev = "9eeaf4f0269bf3936b2d57a67d7c6ba85bb8e6e9" [dependencies.zcash_client_backend] git = "https://github.com/CalDescent1/librustzcash.git" -rev = "1a8686863b10a608ececdede3deb82d2fb4218fa" +rev = "9eeaf4f0269bf3936b2d57a67d7c6ba85bb8e6e9" default-features = false [dependencies.zcash_primitives] git = "https://github.com/CalDescent1/librustzcash.git" -rev = "1a8686863b10a608ececdede3deb82d2fb4218fa" +rev = "9eeaf4f0269bf3936b2d57a67d7c6ba85bb8e6e9" default-features = false features = ["transparent-inputs"] [dependencies.zcash_proofs] git = "https://github.com/CalDescent1/librustzcash.git" -rev = "1a8686863b10a608ececdede3deb82d2fb4218fa" +rev = "9eeaf4f0269bf3936b2d57a67d7c6ba85bb8e6e9" default-features = false [dependencies.ff] git = "https://github.com/CalDescent1/librustzcash.git" -rev = "1a8686863b10a608ececdede3deb82d2fb4218fa" +rev = "9eeaf4f0269bf3936b2d57a67d7c6ba85bb8e6e9" features = ["ff_derive"] [build-dependencies] diff --git a/lib/src/commands.rs b/lib/src/commands.rs index 03bc2f0..c0e690c 100644 --- a/lib/src/commands.rs +++ b/lib/src/commands.rs @@ -674,11 +674,11 @@ impl Command for RedeemP2shCommand { let mut h = vec![]; h.push("Redeem ARRR from an HTLC"); h.push("Usage:"); - h.push("send '{'input':
, 'output': [{'address':
, 'amount': , 'memo': , 'script': , 'txid': , 'secret': , 'privkey': }, ...]}"); + h.push("send '{'input':
, 'output': [{'address':
, 'amount': , 'memo': , 'script': , 'txid': , 'locktime': , 'secret': , 'privkey': }, ...]}"); h.push(""); h.push("NOTE: The fee required to send this transaction (currently ZEC 0.0001) is additionally detected from your balance."); h.push("Example:"); - h.push("send '{\"input\":\"ztestsapling1x65nq4dgp0qfywgxcwk9n0fvm4fysmapgr2q00p85ju252h6l7mmxu2jg9cqqhtvzd69jwhgv8d\", \"output\": [{ \"address\": \"ztestsapling1x65nq4dgp0qfywgxcwk9n0fvm4fysmapgr2q00p85ju252h6l7mmxu2jg9cqqhtvzd69jwhgv8d\", \"amount\": 200000, \"memo\": \"Hello from the command line\", \"script\": \"acbdef\", \"secret\": \"acbdef\", \"privkey\": \"acbdef\"}]}'"); + h.push("send '{\"input\":\"ztestsapling1x65nq4dgp0qfywgxcwk9n0fvm4fysmapgr2q00p85ju252h6l7mmxu2jg9cqqhtvzd69jwhgv8d\", \"output\": [{ \"address\": \"ztestsapling1x65nq4dgp0qfywgxcwk9n0fvm4fysmapgr2q00p85ju252h6l7mmxu2jg9cqqhtvzd69jwhgv8d\", \"amount\": 200000, \"memo\": \"Hello from the command line\", \"script\": \"acbdef\", \"txid\": \"acbdef\", \"locktime\": 1652873471, \"secret\": \"acbdef\", \"privkey\": \"acbdef\"}]}'"); h.push(""); h.join("\n") } @@ -764,6 +764,16 @@ impl Command for RedeemP2shCommand { let txid_bytes = &txid_vec[..]; + //Check for a lock time and convert to u32 + let lock_time: u32 = if json_args.has_key("locktime") { + match json_args["locktime"].as_u32() { + Some(f) => f.clone(), + None => return format!("Error: {}\n{}", "locktime must be a number", self.help()) + } + } else { + return format!("Error: {}\n{}", "Need locktime", self.help()); + }; + //Check for secret and convert to a string let secret58 = if json_args.has_key("secret") { json_args["secret"].as_str().unwrap().to_string().clone() @@ -815,7 +825,7 @@ impl Command for RedeemP2shCommand { Ok(_) => { // Convert to the right format. String -> &str. let tos = send_args.iter().map(|(a, v, m)| (a.as_str(), *v, m.clone()) ).collect::>(); - match lightclient.do_redeem_p2sh(from, tos, &fee, script_bytes, txid_bytes, secret_bytes, privkey_bytes) { + match lightclient.do_redeem_p2sh(from, tos, &fee, script_bytes, txid_bytes, lock_time, secret_bytes, privkey_bytes) { Ok(txid) => { object!{ "txid" => txid } }, Err(e) => { object!{ "error" => e } } }.pretty(2) diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index fe52820..6782763 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -1747,7 +1747,7 @@ impl LightClient { result.map(|(txid, _)| txid) } - pub fn do_redeem_p2sh(&self, from: &str, addrs: Vec<(&str, u64, Option)>, fee: &u64, script: &[u8], txid: &[u8], secret: &[u8], privkey: &[u8]) -> Result { + pub fn do_redeem_p2sh(&self, from: &str, addrs: Vec<(&str, u64, Option)>, fee: &u64, script: &[u8], txid: &[u8], lock_time: u32, secret: &[u8], privkey: &[u8]) -> Result { if !self.wallet.read().unwrap().is_unlocked_for_spending() { error!("Wallet is locked"); return Err("Wallet is locked".to_string()); @@ -1761,7 +1761,7 @@ impl LightClient { self.wallet.write().unwrap().redeem_p2sh( u32::from_str_radix(&self.config.consensus_branch_id, 16).unwrap(), &self.sapling_spend, &self.sapling_output, - from, addrs, script, txid, secret, privkey, fee, + from, addrs, script, txid, lock_time, secret, privkey, fee, |txbytes| broadcast_raw_tx(&self.get_server_uri(), txbytes) ) }; diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index 6ea0e03..4422473 100644 --- a/lib/src/lightwallet.rs +++ b/lib/src/lightwallet.rs @@ -2783,6 +2783,7 @@ impl LightWallet { tos: Vec<(&str, u64, Option)>, redeem_script_pubkey: &[u8], outpoint_txid: &[u8], + lock_time: u32, secret: &[u8], privkey: &[u8], fee: &u64, @@ -2903,7 +2904,7 @@ impl LightWallet { let sk = SecretKey::from_slice(privkey).unwrap(); - if let Err(e) = builder.add_transparent_input_with_secret(sk, outpoint.clone(), coin.clone(), secret.to_vec(), redeem_script_pubkey.to_vec() + if let Err(e) = builder.add_transparent_input_with_secret(sk, outpoint.clone(), coin.clone(), secret.to_vec(), redeem_script_pubkey.to_vec(), lock_time ) { let e = format!("Error adding transparent input: {:?}", e); error!("{}", e);