Skip to content

Commit 597f320

Browse files
committed
[FIXUP] Remove payment proofs from atomic swaps
1 parent b1104ad commit 597f320

File tree

10 files changed

+111
-161
lines changed

10 files changed

+111
-161
lines changed

api/src/foreign_rpc.rs

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub trait ForeignRpc {
5959
}
6060
}
6161
# "#
62-
# ,false, 0, TxFlow::Standard);
62+
# ,false, 0, false, TxFlow::Standard);
6363
```
6464
*/
6565
fn check_version(&self) -> Result<VersionInfo, ErrorKind>;
@@ -107,7 +107,7 @@ pub trait ForeignRpc {
107107
}
108108
}
109109
# "#
110-
# ,false, 4, TxFlow::Standard);
110+
# ,false, 4, false, TxFlow::Standard);
111111
```
112112
*/
113113

@@ -182,7 +182,7 @@ pub trait ForeignRpc {
182182
}
183183
}
184184
# "#
185-
# ,false, 5, TxFlow::Standard);
185+
# ,false, 5, true, TxFlow::Standard);
186186
```
187187
*/
188188
fn receive_tx(
@@ -211,10 +211,6 @@ pub trait ForeignRpc {
211211
"fee": "23500000",
212212
"id": "0436430c-2b02-624c-2032-570501212b00",
213213
"off": "d202964900000000d302964900000000d402964900000000d502964900000000",
214-
"proof": {
215-
"raddr": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3",
216-
"saddr": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3"
217-
},
218214
"sigs": [
219215
{
220216
"nonce": "02b57c1f4fea69a3ee070309cf8f06082022fe06f25a9be1851b56ef0fa18f25d6",
@@ -237,7 +233,6 @@ pub trait ForeignRpc {
237233
"result": {
238234
"Ok": {
239235
"amt": "6000000000",
240-
"atomic_id": "0",
241236
"coms": [
242237
{
243238
"c": "091582c92b99943b57955e52b5ccf1223780c2a2e55995c00c86fca2bcb46b6b9f",
@@ -247,31 +242,25 @@ pub trait ForeignRpc {
247242
"fee": "23500000",
248243
"id": "0436430c-2b02-624c-2032-570501212b00",
249244
"off": "a4f88ac429dee1d453ae33ed9f944417a52c7310477936e484fd83f0f22db483",
250-
"proof": {
251-
"raddr": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3",
252-
"rsig": "02357a13b304ba8e22f4896d5664b72ad6d1b824e88782e2b716686ea14ec47281ef5ee14c03ead84c3260f5b0c1529ad3ddae57f28f6b8b1b66532bfcb2ee0f",
253-
"saddr": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3"
254-
},
255245
"sigs": [
256246
{
257247
"nonce": "02b57c1f4fea69a3ee070309cf8f06082022fe06f25a9be1851b56ef0fa18f25d6",
258248
"xs": "023878ce845727f3a4ec76ca3f3db4b38a2d05d636b8c3632108b857fed63c96de"
259249
},
260250
{
261-
"atomic": "03cefcb7f65194418ee236f01638034238a7c996cd73fa9673e0c763eab828f119",
251+
"atomic": "03e1d14f7b440af4944193b0559452651720ecf1847ef0f7092ef7e68414b8d732",
262252
"nonce": "031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f",
263-
"part": "8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841b1e25843c36d8bdcf87f208666490a16281943a6504209c3ea53fb9f1f7af0cf8",
253+
"part": "8f07ddd5e9f5179cff19486034181ed76505baaad53e5d994064127b56c5841bf9df0f2c4d96d6bb0b2e6e0b94ad6cbbc0e3f9e5582b085b31b5c8bb0e15bd36",
264254
"xs": "02e3c128e436510500616fef3f9a22b15ca015f407c8c5cf96c9059163c873828f"
265255
}
266256
],
267-
"atomic_id": "046d7761746f6d69630000000000000000",
268257
"sta": "A2",
269258
"ver": "4:2"
270259
}
271260
}
272261
}
273262
# "#
274-
# ,false, 5, TxFlow::Atomic);
263+
# ,false, 5, true, TxFlow::Atomic);
275264
```
276265
*/
277266
fn receive_atomic_tx(
@@ -370,7 +359,7 @@ pub trait ForeignRpc {
370359
}
371360
}
372361
# "#
373-
# ,false, 5, TxFlow::Invoice);
362+
# ,false, 5, true, TxFlow::Invoice);
374363
```
375364
*/
376365
fn finalize_tx(&self, slate: VersionedSlate) -> Result<VersionedSlate, ErrorKind>;
@@ -451,6 +440,7 @@ pub fn run_doctest_foreign(
451440
test_dir: &str,
452441
use_token: bool,
453442
blocks_to_mine: u64,
443+
do_tx: bool,
454444
tx_flow: TxFlow,
455445
) -> Result<Option<serde_json::Value>, String> {
456446
use easy_jsonrpc_mw::Handler;
@@ -573,81 +563,84 @@ pub fn run_doctest_foreign(
573563
assert!(wallet_refreshed);
574564
}
575565

576-
match tx_flow {
577-
TxFlow::Invoice => {
578-
let amount = 60_000_000_000;
579-
let mut slate = {
580-
let mut w_lock = wallet2.lock();
566+
if do_tx {
567+
match tx_flow {
568+
TxFlow::Invoice => {
569+
let amount = 60_000_000_000;
570+
let mut slate = {
571+
let mut w_lock = wallet2.lock();
572+
let w = w_lock.lc_provider().unwrap().wallet_inst().unwrap();
573+
let args = IssueInvoiceTxArgs {
574+
amount,
575+
..Default::default()
576+
};
577+
api_impl::owner::issue_invoice_tx(&mut **w, (&mask2).as_ref(), args, true)
578+
.unwrap()
579+
};
580+
slate = {
581+
let mut w_lock = wallet1.lock();
582+
let w = w_lock.lc_provider().unwrap().wallet_inst().unwrap();
583+
let args = InitTxArgs {
584+
src_acct_name: None,
585+
amount: slate.amount,
586+
minimum_confirmations: 2,
587+
max_outputs: 500,
588+
num_change_outputs: 1,
589+
selection_strategy_is_use_all: true,
590+
..Default::default()
591+
};
592+
api_impl::owner::process_invoice_tx(
593+
&mut **w,
594+
(&mask1).as_ref(),
595+
&slate,
596+
args,
597+
true,
598+
)
599+
.unwrap()
600+
};
601+
println!("INIT INVOICE SLATE");
602+
// Spit out slate for input to finalize_tx
603+
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
604+
}
605+
TxFlow::Standard => {
606+
let amount = 60_000_000_000;
607+
let mut w_lock = wallet1.lock();
581608
let w = w_lock.lc_provider().unwrap().wallet_inst().unwrap();
582-
let args = IssueInvoiceTxArgs {
609+
let args = InitTxArgs {
610+
src_acct_name: None,
583611
amount,
612+
minimum_confirmations: 2,
613+
max_outputs: 500,
614+
num_change_outputs: 1,
615+
selection_strategy_is_use_all: true,
584616
..Default::default()
585617
};
586-
api_impl::owner::issue_invoice_tx(&mut **w, (&mask2).as_ref(), args, true).unwrap()
587-
};
588-
slate = {
618+
let slate =
619+
api_impl::owner::init_send_tx(&mut **w, (&mask1).as_ref(), args, true).unwrap();
620+
println!("INIT SLATE");
621+
// Spit out slate for input to finalize_tx
622+
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
623+
}
624+
TxFlow::Atomic => {
625+
let amount = 60_000_000_000;
589626
let mut w_lock = wallet1.lock();
590627
let w = w_lock.lc_provider().unwrap().wallet_inst().unwrap();
591628
let args = InitTxArgs {
592629
src_acct_name: None,
593-
amount: slate.amount,
630+
amount,
594631
minimum_confirmations: 2,
595632
max_outputs: 500,
596633
num_change_outputs: 1,
597634
selection_strategy_is_use_all: true,
598635
..Default::default()
599636
};
600-
api_impl::owner::process_invoice_tx(&mut **w, (&mask1).as_ref(), &slate, args, true)
601-
.unwrap()
602-
};
603-
println!("INIT INVOICE SLATE");
604-
// Spit out slate for input to finalize_tx
605-
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
606-
}
607-
TxFlow::Standard => {
608-
let amount = 60_000_000_000;
609-
let mut w_lock = wallet1.lock();
610-
let w = w_lock.lc_provider().unwrap().wallet_inst().unwrap();
611-
let args = InitTxArgs {
612-
src_acct_name: None,
613-
amount,
614-
minimum_confirmations: 2,
615-
max_outputs: 500,
616-
num_change_outputs: 1,
617-
selection_strategy_is_use_all: true,
618-
..Default::default()
619-
};
620-
let slate =
621-
api_impl::owner::init_send_tx(&mut **w, (&mask1).as_ref(), args, true).unwrap();
622-
println!("INIT SLATE");
623-
// Spit out slate for input to finalize_tx
624-
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
625-
}
626-
TxFlow::Atomic => {
627-
let amount = 60_000_000_000;
628-
let mut w_lock = wallet1.lock();
629-
let w = w_lock.lc_provider().unwrap().wallet_inst().unwrap();
630-
let args = InitTxArgs {
631-
src_acct_name: None,
632-
amount,
633-
minimum_confirmations: 2,
634-
max_outputs: 500,
635-
num_change_outputs: 1,
636-
selection_strategy_is_use_all: true,
637-
..Default::default()
638-
};
639-
let derive_path = 0;
640-
let slate = api_impl::owner::init_atomic_swap(
641-
&mut **w,
642-
(&mask1).as_ref(),
643-
args,
644-
derive_path,
645-
true,
646-
)
647-
.unwrap();
648-
println!("INIT SLATE");
649-
// Spit out slate for input to finalize_tx
650-
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
637+
let slate =
638+
api_impl::owner::init_atomic_swap(&mut **w, (&mask1).as_ref(), args, true)
639+
.unwrap();
640+
println!("INIT SLATE");
641+
// Spit out slate for input to finalize_tx
642+
println!("{}", serde_json::to_string_pretty(&slate).unwrap());
643+
}
651644
}
652645
}
653646

@@ -667,7 +660,7 @@ pub fn run_doctest_foreign(
667660
#[doc(hidden)]
668661
#[macro_export]
669662
macro_rules! doctest_helper_json_rpc_foreign_assert_response {
670-
($request:expr, $expected_response:expr, $use_token:expr, $blocks_to_mine:expr, $tx_flow:expr) => {
663+
($request:expr, $expected_response:expr, $use_token:expr, $blocks_to_mine:expr, $do_tx:expr, $tx_flow:expr) => {
671664
// create temporary wallet, run jsonrpc request on owner api of wallet, delete wallet, return
672665
// json response.
673666
// In order to prevent leaking tempdirs, This function should not panic.
@@ -687,9 +680,16 @@ macro_rules! doctest_helper_json_rpc_foreign_assert_response {
687680
let request_val: Value = serde_json::from_str($request).unwrap();
688681
let expected_response: Value = serde_json::from_str($expected_response).unwrap();
689682

690-
let response = run_doctest_foreign(request_val, dir, $use_token, $blocks_to_mine, $tx_flow)
691-
.unwrap()
692-
.unwrap();
683+
let response = run_doctest_foreign(
684+
request_val,
685+
dir,
686+
$use_token,
687+
$blocks_to_mine,
688+
$do_tx,
689+
$tx_flow,
690+
)
691+
.unwrap()
692+
.unwrap();
693693

694694
if response != expected_response {
695695
panic!(

api/src/owner.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ where
801801
///
802802
/// // . . .
803803
/// // The slate has been recieved from the invoicer, somehow
804+
/// # use grin_wallet_libwallet::TxFlow;
804805
/// # let slate = Slate::blank(2, TxFlow::Invoice);
805806
/// let args = InitTxArgs {
806807
/// src_acct_name: None,
@@ -866,18 +867,11 @@ where
866867
&self,
867868
keychain_mask: Option<&SecretKey>,
868869
args: InitTxArgs,
869-
derive_path: u32,
870870
) -> Result<Slate, Error> {
871871
let mut w_lock = self.wallet_inst.lock();
872872
let w = w_lock.lc_provider()?.wallet_inst()?;
873873
let send_args = args.send_args.clone();
874-
let slate = owner::init_atomic_swap(
875-
&mut **w,
876-
keychain_mask,
877-
args,
878-
derive_path,
879-
self.doctest_mode,
880-
)?;
874+
let slate = owner::init_atomic_swap(&mut **w, keychain_mask, args, self.doctest_mode)?;
881875
if let Some(sa) = send_args {
882876
let tor_config_lock = self.tor_config.lock();
883877
let tc = tor_config_lock.clone();

api/src/owner_rpc.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -619,8 +619,7 @@ pub trait OwnerRpc {
619619
"payment_proof_recipient_address": "tgrin1xtxavwfgs48ckf3gk8wwgcndmn0nt4tvkl8a7ltyejjcy2mc6nfs9gm2lp",
620620
"ttl_blocks": null,
621621
"send_args": null
622-
},
623-
"derive_path": 0
622+
}
624623
},
625624
"id": 1
626625
}
@@ -633,14 +632,9 @@ pub trait OwnerRpc {
633632
"result": {
634633
"Ok": {
635634
"amt": "6000000000",
636-
"atomic_id": "046d7761746f6d69630000000000000000",
637635
"fee": "23000000",
638636
"id": "0436430c-2b02-624c-2032-570501212b00",
639637
"off": "456498224e2a6850e073ab8fb5c32fcccfe70272c61759ea4ade53ae7dc367e6",
640-
"proof": {
641-
"raddr": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3",
642-
"saddr": "32cdd63928854f8b2628b1dce4626ddcdf35d56cb7cfdf7d64cca5822b78d4d3"
643-
},
644638
"sigs": [
645639
{
646640
"nonce": "031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f",
@@ -656,12 +650,8 @@ pub trait OwnerRpc {
656650
# , 4, false, false, false, false, false);
657651
```
658652
*/
659-
fn init_atomic_swap(
660-
&self,
661-
token: Token,
662-
args: InitTxArgs,
663-
derive_path: u32,
664-
) -> Result<VersionedSlate, ErrorKind>;
653+
fn init_atomic_swap(&self, token: Token, args: InitTxArgs)
654+
-> Result<VersionedSlate, ErrorKind>;
665655

666656
/**
667657
Networked version of [Owner::countersign_atomic_swap](struct.Owner.html#method.countersign_atomic_swap).
@@ -714,7 +704,6 @@ pub trait OwnerRpc {
714704
"result": {
715705
"Ok": {
716706
"amt": "60000000000",
717-
"atomic_id": "046d7761746f6d69630000000000000000",
718707
"coms": [
719708
{
720709
"c": "087df32304c5d4ae8b2af0bc31e700019d722910ef87dd4eec3197b80b207e3045",
@@ -727,10 +716,6 @@ pub trait OwnerRpc {
727716
{
728717
"c": "099b48cfb1f80a2347dc89818449e68e76a3c6817a532a8e9ef2b4a5ccf4363850",
729718
"p": "29701ceae262cac77b79b868c883a292e61e6de8192b868edcd1300b0973d91396b156ace6bd673402a303de10ddd8a5e6b7f17ba6557a574a672bd04cc273ab04ed8e2ca80bac483345c0ec843f521814ce1301ec9adc38956a12b4d948acce71295a4f52bcdeb8a1c9f2d6b2da5d731262a5e9c0276ef904df9ef8d48001420cd59f75a2f1ae5c7a1c7c6b9f140e7613e52ef9e249f29f9340b7efb80699e460164324616f98fd4cde3db52497c919e95222fffeacb7e65deca7e368a80ce713c19de7da5369726228ee336f5bd494538c12ccbffeb1b9bfd5fc8906d1c64245b516f103fa96d9c56975837652c1e0fa5803d7ccf1147d8f927e36da717f7ad79471dbe192f5f50f87a79fc3fe030dba569b634b92d2cf307993cce545633af263897cd7e6ebf4dcafb176d07358bdc38d03e45a49dfa9c8c6517cd68d167ffbf6c3b4de0e2dd21909cbad4c467b84e5700be473a39ac59c669d7c155c4bcab9b8026eea3431c779cd277e4922d2b9742e1f6678cbe869ec3b5b7ef4132ddb6cdd06cf27dbeb28be72b949fa897610e48e3a0d789fd2eea75abc97b3dc7e00e5c8b3d24e40c6f24112adb72352b89a2bef0599345338e9e76202a3c46efa6370952b2aca41aadbae0ea32531acafcdab6dd066d769ebf50cf4f3c0a59d2d5fa79600a207b9417c623f76ad05e8cccfcd4038f9448bc40f127ca7c0d372e46074e334fe49f5a956ec0056f4da601e6af80eb1a6c4951054869e665b296d8c14f344ca2dc5fdd5df4a3652536365a1615ad9b422165c77bf8fe65a835c8e0c41e070014eb66ef8c525204e990b3a3d663c1e42221b496895c37a2f0c1bf05e91235409c3fe3d89a9a79d6c78609ab18a463311911f71fa37bb73b15fcd38143d1404fd2ce81004dc7ff89cf1115dcc0c35ce1c1bf9941586fb959770f2618ccb7118a7"
730-
},
731-
{
732-
"c": "09ede20409d5ae0d1c0d3f3d2c68038a384cdd6b7cc5ca2aab670f570adc2dffc3",
733-
"p": "6d86fe00220f8c6ac2ad4e338d80063dba5423af525bd273ecfac8ef6b509192732a8cd0c53d3313e663ac5ccece3d589fd2634e29f96e82b99ca6f8b953645a005d1bc73493f8c41f84fb8e327d4cbe6711dba194a60db30700df94a41e1fda7afe0619169389f8d8ee12bddf736c4bc86cd5b1809a5a27f195209147dc38d0de6f6710ce9350f3b8e7e6820bfe5182e6e58f0b41b82b6ec6bb01ffe1d8b3c2368ebf1e31dfdb9e00f0bc68d9119a38d19c038c29c7b37e31246e7bba56019bc88881d7d695d32557fc0e93635b5f24deffefc787787144e5de7e86281e79934e7e20d9408c34317c778e6b218ee26d0a5e56b8b84a883e3ddf8603826010234531281486454f8c2cf3fee074f242f9fc1da3c6636b86fb6f941eb8b633d6e3b3f87dfe5ae261a40190bd4636f433bcdd5e3400255594e282c5396db8999d95be08a35be9a8f70fdb7cf5353b90584523daee6e27e208b2ca0e5758b8a24b974dca00bab162505a2aa4bcefd8320f111240b62f861261f0ce9b35979f9f92da7dd6989fe1f41ec46049fd514d9142ce23755f52ec7e64df2af33579e9b8356171b91bc96b875511bef6062dd59ef3fe2ddcc152147554405b12c7c5231513405eb062aa8fa093e3414a144c544d551c4f1f9bf5d5d2ff5b50a3f296c800907704bed8d8ee948c0855eff65ad44413af641cdc68a06a7c855be7ed7dd64d5f623bbc9645763d48774ba2258240a83f8f89ef84d21c65bcb75895ebca08b0090b40aafb7ddef039fcaf4bad2dbbac72336c4412c600e854d368ed775597c15d2e66775ab47024ce7e62fd31bf90b183149990c10b5b678501dbac1af8b2897b67d085d87cab7af4036cba3bdcfdcc7548d7710511045813c6818d859e192e03adc0d6a6b30c4cbac20a0d6f8719c7a9c3ad46d62eec464c4c44b58fca463fea3ce1fc51"
734719
}
735720
],
736721
"fee": "23500000",
@@ -2000,11 +1985,9 @@ where
20001985
&self,
20011986
token: Token,
20021987
args: InitTxArgs,
2003-
derive_path: u32,
20041988
) -> Result<VersionedSlate, ErrorKind> {
2005-
let out_slate =
2006-
Owner::init_atomic_swap(self, (&token.keychain_mask).as_ref(), args, derive_path)
2007-
.map_err(|e| e.kind())?;
1989+
let out_slate = Owner::init_atomic_swap(self, (&token.keychain_mask).as_ref(), args)
1990+
.map_err(|e| e.kind())?;
20081991
let version = SlateVersion::V4;
20091992
Ok(VersionedSlate::into_version(out_slate, version).map_err(|e| e.kind())?)
20101993
}
@@ -2484,7 +2467,7 @@ pub fn run_doctest_owner(
24842467
..Default::default()
24852468
};
24862469
let mut slate = if countersign_atomic {
2487-
api_impl::owner::init_atomic_swap(&mut **w, (&mask1).as_ref(), args, 0, true).unwrap()
2470+
api_impl::owner::init_atomic_swap(&mut **w, (&mask1).as_ref(), args, true).unwrap()
24882471
} else {
24892472
api_impl::owner::init_send_tx(&mut **w, (&mask1).as_ref(), args, true).unwrap()
24902473
};

api/tests/slate_versioning.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn _receive_versioned_slate() {
5353
let request_val: Value = serde_json::from_str(v1_req).unwrap();
5454
let expected_response: Value = serde_json::from_str(v1_resp).unwrap();
5555

56-
let response = run_doctest_foreign(request_val, dir, false, 5, TxFlow::Standard)
56+
let response = run_doctest_foreign(request_val, dir, false, 5, false, TxFlow::Standard)
5757
.unwrap()
5858
.unwrap();
5959

0 commit comments

Comments
 (0)