From 7c65e566c44268954654d9ff3e1c26b1e1d16167 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Mon, 3 Aug 2020 10:49:29 +0200 Subject: [PATCH] new checkpoint, add to mempool only if broadcast port from https://github.com/adityapk00/zecwallet-light-cli/commit/b171d28586b00ed7c94b05eee61606eb9d8bd475 --- lib/src/lightclient.rs | 10 ++- lib/src/lightclient/checkpoints.rs | 62 +++++++++++++++--- lib/src/lightwallet.rs | 20 ++++-- lib/src/lightwallet/tests.rs | 102 ++++++++++++++--------------- 4 files changed, 121 insertions(+), 73 deletions(-) diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index 545a4eb..47a2ed9 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -1277,20 +1277,18 @@ impl LightClient { info!("Creating transaction"); - let rawtx = { + let result = { 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 + addrs, + |txbytes| broadcast_raw_tx(&self.get_server_uri(), self.config.no_cert_verification, txbytes) ) }; - match rawtx { - Ok(txbytes) => broadcast_raw_tx(&self.get_server_uri(), self.config.no_cert_verification, txbytes), - Err(e) => Err(format!("Error: No Tx to broadcast. Error was: {}", e)) - } + result.map(|(txid, _)| txid) } } diff --git a/lib/src/lightclient/checkpoints.rs b/lib/src/lightclient/checkpoints.rs index f94a9b1..8bcf272 100644 --- a/lib/src/lightclient/checkpoints.rs +++ b/lib/src/lightclient/checkpoints.rs @@ -25,19 +25,63 @@ fn get_main_checkpoint(height: u64) -> Option<(u64, &'static str, &'static str) let checkpoints: Vec<(u64, &str, &str)> = vec![ (160000, "0000000553274de0e5f07bf3a63bdb6ab71158a3506829fd6f7df2cd51d5b2a3", - "0175d619624f48e45df658b143f5239e22addf620d7000013dfd62298688ecb350015e464e8e594499a624a5d20e323a4de304ace8ec20b63cb41f5ed08629c678720f000001b90f0634e468eb3d2de0985c661fb9b7b8a081e4443147d617377a337c1dd13901152f108238acfd96b7b734333b0d3927d77812aa9648eef969de78c1daef023f019f3b14a209c15a14ddd3bd49355759c151ddcc1b7816fc472c7d9053f3495c6100000180623c9995f068e60c7fc0b9423eb753cc85ee8aa8df47c273ebb202dbf43f230000000001ef041d21ca2e599aca269d5a63b35f5ac2abe8e776279fb09ae902778b33746301982a0ad78d7d67d3c7b026adfdb342eceb50557cb4677ec43742028c4602216701b8d79586ce15b0cd9b3683091dea42cdad3fa4dc6d7d7853aaac062aa5717527" - ), + "0175d619624f48e45df658b143f5239e22addf620d7000013dfd62298688ecb350015e464e8e594499a624a5d20e323a4de304ace8ec20b63cb41f5ed08629c678720f000001b90f0634e468eb3d2de0985c661fb9b7b8a081e4443147d617377a337c1dd13901152f108238acfd96b7b734333b0d3927d77812aa9648eef969de78c1daef023f019f3b14a209c15a14ddd3bd49355759c151ddcc1b7816fc472c7d9053f3495c6100000180623c9995f068e60c7fc0b9423eb753cc85ee8aa8df47c273ebb202dbf43f230000000001ef041d21ca2e599aca269d5a63b35f5ac2abe8e776279fb09ae902778b33746301982a0ad78d7d67d3c7b026adfdb342eceb50557cb4677ec43742028c4602216701b8d79586ce15b0cd9b3683091dea42cdad3fa4dc6d7d7853aaac062aa5717527" +), - (170000, "0000000191d6e3c5473215ab1e28a8fa8db6172eb4ec6fed371d4bd71224adb0", +(170000, "0000000191d6e3c5473215ab1e28a8fa8db6172eb4ec6fed371d4bd71224adb0", - "019081dbde619339e0e85a13df8ff833ea866502d96d9839242eaf4e6f89a9935b000f00000001b542d70d235bfef8c3ea401fc7682c4889abc1d8047346ec374a846e498cf44f013317e59dfbc56000b20131e73d531dd805c481978f86c055b2f863ea7f0b296b01e0bc6b4ae0036aecc0973669061d777fe00f33c19d561cb89f9d8fef5d9d35100001d4ce711d7659419f11c307a77ab79c0fc2f62d1e7b2fc650d6a51704bcf31223017c86ee02304db5f5158a4186cc65e9ceb6acdf88877ea59f5184b04ada15bf0c01d3b830cc0959d5c6616a2eb11231763576719f844da23aafeb3ddcd44dcbb262017cda15fd9d8af2559d2fa920983b832ef410d10811cab7e678ee788d4a74df0a0001ef041d21ca2e599aca269d5a63b35f5ac2abe8e776279fb09ae902778b33746301982a0ad78d7d67d3c7b026adfdb342eceb50557cb4677ec43742028c4602216701b8d79586ce15b0cd9b3683091dea42cdad3fa4dc6d7d7853aaac062aa5717527" - ), + "019081dbde619339e0e85a13df8ff833ea866502d96d9839242eaf4e6f89a9935b000f00000001b542d70d235bfef8c3ea401fc7682c4889abc1d8047346ec374a846e498cf44f013317e59dfbc56000b20131e73d531dd805c481978f86c055b2f863ea7f0b296b01e0bc6b4ae0036aecc0973669061d777fe00f33c19d561cb89f9d8fef5d9d35100001d4ce711d7659419f11c307a77ab79c0fc2f62d1e7b2fc650d6a51704bcf31223017c86ee02304db5f5158a4186cc65e9ceb6acdf88877ea59f5184b04ada15bf0c01d3b830cc0959d5c6616a2eb11231763576719f844da23aafeb3ddcd44dcbb262017cda15fd9d8af2559d2fa920983b832ef410d10811cab7e678ee788d4a74df0a0001ef041d21ca2e599aca269d5a63b35f5ac2abe8e776279fb09ae902778b33746301982a0ad78d7d67d3c7b026adfdb342eceb50557cb4677ec43742028c4602216701b8d79586ce15b0cd9b3683091dea42cdad3fa4dc6d7d7853aaac062aa5717527" +), +(180000, "00000003119d28eed1fd0c2e2a33510b2b740c1227a9e0e59157228f8e9e1666", - (220000, "00000000dd40d7372e60da03205bfc9bd796cc467737e093a58ab08b688014a4", + "01d44ae837c1bd606ca2e381888ed341125ab055ffe711813ead0f5749b8fdff46000f011924022fa6d2c3d9e678726187acaca4b3a6037c3a124da0ab175a00336bd81b0000014c60efb44ed79ccdaef391ec2c5f332a69c0f8392e1016ba10f16cb16660580e0000012fd7e1d962d22e828935a3b36837d5d6fd8910cf85d385b36a4907cb2610a14c0000014fbef83f690b2abff00fa462dab58cb3e8c4ef3c2ec1a8e6df86698d9138c70201591279b7fbb4cf7476f3c1aa47b2950e4c8c9be0eeed953559d808cc699ce45801245ea322da38fe5fc1ff468ab759c8583f66323c83808a9a1b368d407267a95101ef041d21ca2e599aca269d5a63b35f5ac2abe8e776279fb09ae902778b33746301982a0ad78d7d67d3c7b026adfdb342eceb50557cb4677ec43742028c4602216701b8d79586ce15b0cd9b3683091dea42cdad3fa4dc6d7d7853aaac062aa5717527" +), - "01cf87373bc969942c2cc6dc2cb399c4eaae1d234cc785b1decae4847eb7a21c04001001f2cd27d01566c2594f6bd1d141bc68c2c5b6d7b9c27f1183780636255332b16b01b85d3ab8c19e4fa3f717e48354cd97d416b1a916b0e642777f61aa4b75359b39000000015ae551df3653030b6d6aaf858df93741290191de721b502059baf88d7d56906c016deb46b4029552954f58f0271104a1a2d16838ce5cb8e6adef9aed3c29ea271c000001911852d57122315ab96dce00ca98cf3b3dfc423759610f047a9efd8f57172656000183e3743bb17818ab1f0af4b5d4f564eabef0ff4fbf7e21c4a8f02c91d9963a3e0139bc58e226e9585cb428cf367505f04984e6cf5d91514622a3895b8a8079cb2a0122fd7dee5fcd9788ea5c5d2d3c7a61ec8e9bc667daf380d8361b888e52788f09000130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" - ), - ]; +(190000, "000000002beb4cc8e79a3aed7b1b8329b31a55a3e1556b0933953450a0c185b9", + + "0106dee2956278c131481595fe5bddd6d5513333e4d4a70ab30f6275679bb5366f01b0f3818a593db7414ece7bd18f8b4e7d1ae72256e2c143793677ddf1398ff3121001da0b3775b09fb76c4fa8d858f382429b77701970480fc40c5820098e83106b020001e7e8645779ffba371a89bf5b81995ffba699ebe3f21ceacd2c9141f4c149480a000000014dcd13ab6c374e68740eca74a8e32a0504d18efb95e1addef8c7eb3dd37d871900014cc7b7b8033339db8b64d6359d1c85001026e804323be83aca5712412fd16f5d0000010d16f6ce029ee1775284c5242a5dbf0598468bf900b3f9f388f9c848b06e8f2e0000000130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" +), + +(200000, "00000003d57cdb7fba2f3b641d288737945de2434adeb0b3b3f2ef35a66e45ab", + + "01148cebd3c73692327e7d2478204995421827675c4d2d5d8b45fdb6c27323eb01001001475aa10666c189c0efac20288a73ab973ff3f3b368fc9a7962e3c68ad2e3f3700001c08f19e6d9697f7c6f0cac478e361e8fc5fc7b9cbc7811985399ad40aa59612b0001d49974320917f2293192d4f255367f840e1d9116c5bdd7abeb2758d6c580e456000137c2947b2e40c81be5fa76349f73db0d7991c059bb7980427c6d820a73530b1b012209e59f68592e874f64904dcc7fc7edfdbd32e173f17f7b7df4c5e2774d29380001dc67c97dc64102494f47459ac1d9f0fe74c0c13d969782b32fcf826d6568c467013e24cd3f8025fc104c1e09dbca208aff6ce5116138d6970e7e6c702c5b112960012dedb761d5bf200fa7f87e9c8698e472f53cb7967aabf4c569a10078dcdd340b01080e9e66b5454944a5fe7da7dd2ed0ab65a7a1ffcf64c72667ea7e58c808f02b00000130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" +), + +(210000, "000000006e43c9650b62ae15d05ada7d12be75df37a8b600b636268b144e2aab", + + "0129f97fb8503fb1febf895db8e9a18739b25b1acd84965047fe058fdb8b852b32012b1a6a414233bf56869f3102d6a6ffa80652e20539831ca2093326f35c1f90131000015bde07b0523d9e58ba85a9cff66425ff25f7a9a5d978917ec30ddb2745b43660018088c4a5c82f63af718d67d274c4b59140442fddbe13ed51cbecf343146fac5c00000001ee819cb43cb8f5ad473f9284364729f9e87576fe8e4df185ec43880c8bf48c2a0181a934c030e32e468f9f356cae69106e3dbf754cd387939677c84938bac5c53600012edf33ae091a89e80c2efd8aee9f7f5be82526767b7ce3727e659f78d65f5a30000156182bb69d876492ad1ad59a64bfa2c94c9808ab891a904e0ca52155c08d4b28000122fd7dee5fcd9788ea5c5d2d3c7a61ec8e9bc667daf380d8361b888e52788f09000130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" +), + +(220000, "00000000dd40d7372e60da03205bfc9bd796cc467737e093a58ab08b688014a4", + + "01cf87373bc969942c2cc6dc2cb399c4eaae1d234cc785b1decae4847eb7a21c04001001f2cd27d01566c2594f6bd1d141bc68c2c5b6d7b9c27f1183780636255332b16b01b85d3ab8c19e4fa3f717e48354cd97d416b1a916b0e642777f61aa4b75359b39000000015ae551df3653030b6d6aaf858df93741290191de721b502059baf88d7d56906c016deb46b4029552954f58f0271104a1a2d16838ce5cb8e6adef9aed3c29ea271c000001911852d57122315ab96dce00ca98cf3b3dfc423759610f047a9efd8f57172656000183e3743bb17818ab1f0af4b5d4f564eabef0ff4fbf7e21c4a8f02c91d9963a3e0139bc58e226e9585cb428cf367505f04984e6cf5d91514622a3895b8a8079cb2a0122fd7dee5fcd9788ea5c5d2d3c7a61ec8e9bc667daf380d8361b888e52788f09000130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" +), + +(230000, "000000015b0545acc87aa652a8d8d5aac1ecfc5e15d9e3a9e4171d472fdfa9b4", + + "01aa45e85b57a22504d14f741b9d77041d67a75b2b31394b4fb0cdc6337848025b00100001614763fd4c1dce9dcd7b3f624aa427942629b2295817d37a2d031424834d6e5e000000015d66d62437dae4e7dbecb48895aebb686e39adeea5a3a89162085fcc16cdd25d000165bf3d59adeffdbf313f4b2ade69ec04f7795e09794bb060b798f1f87484c82e0001a978cf87385e1841f24a8243c47b07097ef55ef3d56b14b6b8c05a4fc626a7010185e8209c95a162512ce15ec9be8276afa2390a0e362e08ba9c2e65009ebba55c01106fc764d9ff95d8f8340f514da8bd395451ae0bf3a2cb78c1ddacd407da9b66000001bbab4f57b3298599502cb7fe6f08271006fd8c6f45ebcdbba4db8a33efe42a370130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" +), + +(240000, "000000013e22209c4587e7fce090b7219f2d96640172697d276b606cf53ce07b", + + "019ca121fd854eccede763e93a22b1e09ab9eec63604ef66a0024535b69cfecb17001000000000000001ae3f1d7f9da267bb0e03ce380bc8b1acc23e276eba2347939e2c49aad207c75c011e26f8193532ad33f03a258e782694c7cb049b8dc4e78ee2a87980f9d8972a2900016be46533be28b46d32c3d68329cbd9626ad7e66dfe77e863104a296bb5dda12200000001aa689be876025869ea246310586d5c6585fc15b7013520bfe3ab15301adbb72201bbab4f57b3298599502cb7fe6f08271006fd8c6f45ebcdbba4db8a33efe42a370130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" +), + +(250000, "00000003cba3713646dc533b75fba6f6fe02779e4fb934cda4fe2109c9403268", + +"01b491cf36e95291272eb3b7ded219ddb10d308ab6ccb99fb9a175f6b6020e3606001001e295d93ca54a4cb950d176919a0bc7c0c98daca456e73b81042d8325a2306a3801ad212fe86de149c1f4cacc6ef437b9f82098e2d23e47efe1570010fde4c62d1e0143ce85204dce13fe02527b6ebf27e4d5af94be2931e7dcfcbf98eb21a073362901a9cde0e08f89652d37625a63cabc486121a3fa2a587aa563e0f726f5fc701751012e77965d51a0e01f25073b8a9f6168df9cd1f3ab844d36ef58db8ee1fa02906a010791a49844c2feb6c34cc9617773372acf7dccaa5c2a69ef6c5de67b4eadf46c0152374dca90ace46d24c07115f12f2cb469170d01048752c3ae129ea51557f44b01aef0d6f1ce48072241980dae21715517bfcc69eddd499382f61b0c1d38cb313601d978fd45cbf288e063c783226becaf937ffeefd8e55d085f22f82922f6de7b0b01accf3c3c5871a4d66a0031112a6a2282c265e95e1402b06b52ebdd7307eeaf5f0000012cadfdc5952c78f13b2f5b67f544f6f4b2fc6a4a87227be96196d3da93aba15701aa689be876025869ea246310586d5c6585fc15b7013520bfe3ab15301adbb72201bbab4f57b3298599502cb7fe6f08271006fd8c6f45ebcdbba4db8a33efe42a370130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" +), + +(260000, "00000001f2dc5f292d9ee232d463faf1bc59362b9b3432f5bd1f72ffc76716f8", + +"012713b68800b2b26a90edddde497f39574fc79fcbbd3abbf5201299e92b24982a00100001900dda253ef5c886f9f5b1d4ec6208e13be23db48f34643995b4710f7c9b154e0001157f4d00c85a744085be70a23bff48fb9fedb5450d26f71dc188b55589ce9b4a000001e695cca82b5f79d2efd87e970a9d59d08f0e38933d5845fc5f65c0ae04904f520001ca0d575f716680bb4c37c600f46db9aec62008fff03b75aab3030f5151f80a540001ce2cfbe86a3b6da4f13471aedc066fdc686b6d89b0a857c3c788d30adebbe86e018b9a1cb81bc08041d80850f2da32920c6f41c99746807e9d3b2c4c67756e2e6e012cadfdc5952c78f13b2f5b67f544f6f4b2fc6a4a87227be96196d3da93aba15701aa689be876025869ea246310586d5c6585fc15b7013520bfe3ab15301adbb72201bbab4f57b3298599502cb7fe6f08271006fd8c6f45ebcdbba4db8a33efe42a370130195f8f73dc864a32004ff13f5fa2fed32723a150a498f593590ccec493e004" +), + +(270000, "000000026cc545eed18b508c3368cd20256c012bfa10f5f115b21ad0101c02cb", + +"01994f552eccb1c7e9d9eb883627d062792db872b8201a2ec2ce3620fbd7a3c757001101d060165f1156bc1274e7421b1c386cf38e1a1a0022ecd2856af9930fe5b9ce4f00011ca156cf71adc4122768deb7497fef31a45a38daccfc68d7cd04f4b2a4394f6601e4ad07bc4edd97271886a33bba67bcb7d013027b54c1728f4192ceb7b01c02660136690f3b4c30ee836802c2efc70b241896d26007b20316479ecc42716d3d421500000000016644a968a2e9fbba4252a811c46431dbabfa8cc88881a991e6470068a461fd240001ddbdab31cf067f4478e78adb9a03991d1f62ecf171cbf5f19e65671ad84d016a000000000199d67314660501d57c69466623f01bea8f1ba1fd96f9fceb98d545e7632d9841" +), +]; find_checkpoint(height, checkpoints) } diff --git a/lib/src/lightwallet.rs b/lib/src/lightwallet.rs index d959355..0c2446c 100644 --- a/lib/src/lightwallet.rs +++ b/lib/src/lightwallet.rs @@ -1737,13 +1737,16 @@ impl LightWallet { Ok(all_txs) } - pub fn send_to_address( + pub fn send_to_address ( &self, consensus_branch_id: u32, spend_params: &[u8], output_params: &[u8], - tos: Vec<(&str, u64, Option)> - ) -> Result, String> { + tos: Vec<(&str, u64, Option)>, + broadcast_fn: F + ) -> Result<(String, Vec), String> + where F: Fn(Box<[u8]>) -> Result + { 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 diff --git a/lib/src/lightwallet/tests.rs b/lib/src/lightwallet/tests.rs index 0a2a2e3..e4853d2 100644 --- a/lib/src/lightwallet/tests.rs +++ b/lib/src/lightwallet/tests.rs @@ -713,8 +713,8 @@ fn test_z_spend_to_z() { } // Create a tx and send to address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, None)], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -828,8 +828,8 @@ fn test_self_txns_ttoz_withmemo() { let (ss, so) =get_sapling_params().unwrap(); // Create a tx and send to address. This should consume both the UTXO and the note - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&zaddr, AMOUNT_SENT, Some(outgoing_memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -922,8 +922,8 @@ fn test_self_txns_ztoz() { let (ss, so) =get_sapling_params().unwrap(); // Create a tx and send to address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&zaddr2, AMOUNT_SENT, Some(outgoing_memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&zaddr2, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -942,8 +942,8 @@ fn test_self_txns_ztoz() { } // Another self tx, this time without a memo - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&zaddr2, AMOUNT_SENT, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&zaddr2, AMOUNT_SENT, None)], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -978,8 +978,8 @@ fn test_multi_z() { let (ss, so) =get_sapling_params().unwrap(); // Create a tx and send to address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&zaddr2, AMOUNT_SENT, Some(outgoing_memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&zaddr2, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -1033,8 +1033,8 @@ fn test_multi_z() { let amount_all:u64 = (AMOUNT1 - AMOUNT_SENT - fee) + (AMOUNT_SENT) - fee; let taddr = wallet.address_from_sk(&SecretKey::from_slice(&[1u8; 32]).unwrap()); - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr, amount_all, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&taddr, amount_all, None)], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_ext_txid = sent_tx.txid(); @@ -1075,8 +1075,8 @@ fn test_z_spend_to_taddr() { const AMOUNT_SENT: u64 = 30; let fee: u64 = DEFAULT_FEE.try_into().unwrap(); - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr, AMOUNT_SENT, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&taddr, AMOUNT_SENT, None)], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -1123,8 +1123,8 @@ fn test_z_spend_to_taddr() { } // Create a new Tx, but this time with a memo. - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr, AMOUNT_SENT, Some("T address memo".to_string()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&taddr, AMOUNT_SENT, Some("T address memo".to_string()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid2 = sent_tx.txid(); @@ -1198,8 +1198,8 @@ fn test_t_spend_to_z() { let (ss, so) =get_sapling_params().unwrap(); // Create a tx and send to address. This should consume both the UTXO and the note - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -1272,8 +1272,8 @@ fn test_z_incoming_memo() { let (ss, so) = get_sapling_params().unwrap(); // Create a tx and send to address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&my_address, AMOUNT1 - fee, Some(memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -1315,8 +1315,8 @@ fn test_add_new_zt_hd_after_incoming() { assert_eq!(wallet.zaddress.read().unwrap().len(), 6); // Starts with 1+5 addresses // Create a tx and send to the last address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&my_address, AMOUNT1 - fee, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); // Add it to a block @@ -1358,8 +1358,8 @@ fn test_z_to_t_withinwallet() { let (ss, so) = get_sapling_params().unwrap(); // Create a tx and send to address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr, AMOUNT_SENT, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -1418,8 +1418,8 @@ fn test_multi_t() { let (ss, so) = get_sapling_params().unwrap(); // Create a Tx and send to the second t address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr2, AMOUNT_SENT1, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid1 = sent_tx.txid(); @@ -1462,8 +1462,8 @@ fn test_multi_t() { let taddr3 = wallet.add_taddr(); // Create a Tx and send to the second t address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr3, AMOUNT_SENT2, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid2 = sent_tx.txid(); @@ -1499,8 +1499,8 @@ fn test_multi_t() { let outgoing_memo = "Outgoing Memo".to_string(); // Create a tx and send to address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&ext_address, AMOUNT_SENT_EXT, Some(outgoing_memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid3 = sent_tx.txid(); @@ -1557,7 +1557,7 @@ fn test_multi_spends() { (taddr2.as_str(), TAMOUNT2, None), (taddr3.as_str(), TAMOUNT3, None) ]; - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, tos).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, tos, |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -1629,7 +1629,7 @@ fn test_multi_spends() { let tos = vec![ (ext_address.as_str(), EXT_ZADDR_AMOUNT, Some(ext_memo.clone())), (ext_taddr.as_str(), ext_taddr_amount, None)]; - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, tos).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, tos, |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid2 = sent_tx.txid(); @@ -1682,16 +1682,16 @@ fn test_bad_send() { // Bad address let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&"badaddress", 10, None)]); + vec![(&"badaddress", 10, None)], |_| Ok(' '.to_string())); assert!(raw_tx.err().unwrap().contains("Invalid recipient address")); // Insufficient funds let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&ext_taddr, AMOUNT1 + 10, None)]); + vec![(&ext_taddr, AMOUNT1 + 10, None)], |_| Ok(' '.to_string())); assert!(raw_tx.err().unwrap().contains("Insufficient verified funds")); // No addresses - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, vec![]); + let raw_tx = wallet.send_to_address(branch_id, &ss, &so, vec![], |_| Ok(' '.to_string())); assert!(raw_tx.err().unwrap().contains("at least one")); } @@ -1712,7 +1712,7 @@ fn test_duplicate_outputs() { let raw_tx = wallet.send_to_address(branch_id, &ss, &so, vec![(&ext_taddr, 100, Some("First memo".to_string())), (&ext_taddr, 0, Some("Second memo".to_string())), - (&ext_taddr, 0, Some("Third memo".to_string()))]); + (&ext_taddr, 0, Some("Third memo".to_string()))], |_| Ok(' '.to_string())); assert!(raw_tx.is_ok()); } @@ -1725,7 +1725,7 @@ fn test_bad_params() { let branch_id = u32::from_str_radix("76b809bb", 16).unwrap(); // Bad params let _ = wallet.send_to_address(branch_id, &[], &[], - vec![(&ext_taddr, 10, None)]); + vec![(&ext_taddr, 10, None)], |_| Ok(' '.to_string())); } /// Test helper to add blocks @@ -1761,8 +1761,8 @@ fn test_z_mempool_expiry() { let (ss, so) = get_sapling_params().unwrap(); // Create a tx and send to address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -1878,8 +1878,8 @@ fn test_rollback() { // Create a tx and send to address const AMOUNT_SENT: u64 = 30000; let fee: u64 = DEFAULT_FEE.try_into().unwrap(); - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr, AMOUNT_SENT, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&taddr, AMOUNT_SENT, None)], |_| Ok(' '.to_string())).unwrap(); let sent_tx = Transaction::read(&raw_tx[..]).unwrap(); let sent_txid = sent_tx.txid(); @@ -2142,8 +2142,8 @@ fn test_encrypted_zreceive() { let (ss, so) = get_sapling_params().unwrap(); // Create a tx and send to address - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&ext_address, AMOUNT_SENT, Some(outgoing_memo.clone()))], |_| Ok(' '.to_string())).unwrap(); // Now that we have the transaction, we'll encrypt the wallet wallet.encrypt(password.clone()).unwrap(); @@ -2186,7 +2186,7 @@ fn test_encrypted_zreceive() { // Trying to spend from a locked wallet is an error assert!(wallet.send_to_address(branch_id, &ss, &so, - vec![(&ext_address, AMOUNT_SENT, None)]).is_err()); + vec![(&ext_address, AMOUNT_SENT, None)], |_| Ok(' '.to_string())).is_err()); // unlock the wallet so we can spend to the second z address wallet.unlock(password.clone()).unwrap(); @@ -2196,8 +2196,8 @@ fn test_encrypted_zreceive() { const ZAMOUNT2:u64 = 30; let outgoing_memo2 = "Outgoing Memo2".to_string(); - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&zaddr2, ZAMOUNT2, Some(outgoing_memo2.clone()))]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&zaddr2, ZAMOUNT2, Some(outgoing_memo2.clone()))], |_| Ok(' '.to_string())).unwrap(); // Now lock the wallet again wallet.lock().unwrap(); @@ -2251,8 +2251,8 @@ fn test_encrypted_treceive() { const AMOUNT_SENT: u64 = 30; let fee: u64 = DEFAULT_FEE.try_into().unwrap(); - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr, AMOUNT_SENT, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&taddr, AMOUNT_SENT, None)], |_| Ok(' '.to_string())).unwrap(); // Now that we have the transaction, we'll encrypt the wallet wallet.encrypt(password.clone()).unwrap(); @@ -2288,7 +2288,7 @@ fn test_encrypted_treceive() { // Trying to spend from a locked wallet is an error assert!(wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr, AMOUNT_SENT, None)]).is_err()); + vec![(&taddr, AMOUNT_SENT, None)], |_| Ok(' '.to_string())).is_err()); // unlock the wallet so we can spend to the second z address wallet.unlock(password.clone()).unwrap(); @@ -2297,8 +2297,8 @@ fn test_encrypted_treceive() { let taddr2 = wallet.add_taddr(); const TAMOUNT2:u64 = 50; - let raw_tx = wallet.send_to_address(branch_id, &ss, &so, - vec![(&taddr2, TAMOUNT2, None)]).unwrap(); + let (_, raw_tx) = wallet.send_to_address(branch_id, &ss, &so, + vec![(&taddr2, TAMOUNT2, None)], |_| Ok(' '.to_string())).unwrap(); // Now lock the wallet again wallet.lock().unwrap();