-
Notifications
You must be signed in to change notification settings - Fork 117
[r2r] broadcast tx to txhlp / refactor tx errors #1245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
daeafc8
860163c
43862b6
b02ce08
f3747f7
7acdd35
06ecd56
5a73d5d
9a4c496
4a5d9c5
a9f2e6b
840d022
658ff56
f8ed4cc
fedbc32
78d64e3
e9d16a9
8545045
5c24769
1c3d7bd
b11fe2c
98df7cf
b1f9745
f136301
9a203e7
b6c8ecb
d10d4a9
3a2b0e9
3299524
d2cbe7b
6534913
1778350
903526f
6b9e579
19a493d
aa43384
21f2b6a
7811106
9c9db1c
f461dcc
bad90b6
8ca638f
ed574a5
46ad808
d456326
7e6c215
9444eda
5ba0dd1
f87cef3
21f9684
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1083,17 +1083,11 @@ impl MarketCoinOps for SlpToken { | |
|
|
||
| /// Receives raw transaction bytes in hexadecimal format as input and returns tx hash in hexadecimal format | ||
| fn send_raw_tx(&self, tx: &str) -> Box<dyn Future<Item = String, Error = String> + Send> { | ||
| let coin = self.clone(); | ||
| let tx = tx.to_owned(); | ||
| let fut = async move { | ||
| let bytes = hex::decode(tx).map_to_mm(|e| e).map_err(|e| format!("{:?}", e))?; | ||
| let tx = deserialize(bytes.as_slice()) | ||
| .map_to_mm(|e| e) | ||
| .map_err(|e| format!("{:?}", e))?; | ||
| let hash = coin.broadcast_tx(&tx).await.map_err(|e| format!("{:?}", e))?; | ||
| Ok(format!("{:?}", hash)) | ||
| }; | ||
| Box::new(fut.boxed().compat()) | ||
| utxo_common::send_raw_tx(self.as_ref(), tx) | ||
| } | ||
|
|
||
| fn send_raw_tx_bytes(&self, tx: &[u8]) -> Box<dyn Future<Item = String, Error = String> + Send> { | ||
| utxo_common::send_raw_tx(self.as_ref(), tx) | ||
| } | ||
|
|
||
| fn wait_for_confirmations( | ||
|
|
@@ -2022,7 +2016,7 @@ mod slp_tests { | |
|
|
||
| let err = fusd.send_raw_tx(&tx_bytes_str).wait().unwrap_err(); | ||
| println!("{:?}", err); | ||
| assert!(err.contains("is not valid with reason outputs greater than inputs")); | ||
| assert!(err.contains("the transaction was rejected by network rules.\\n\\ntransaction already in block chain")); | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This had to change since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ozkanonur Very good that we have this test 🙂 The usage of validation code Could you please roll back the Also, if the test started to fail, it's undesirable to change it - there's a very high chance that tested code got broken. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
PS, even if I asked to change the code on the review 🙂 I can be wrong.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
|
||
| let utxo_tx: UtxoTx = deserialize(tx_bytes).unwrap(); | ||
| let err = block_on(fusd.broadcast_tx(&utxo_tx)).unwrap_err(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ use super::{broadcast_my_swap_status, broadcast_swap_message_every, check_other_ | |
| use crate::mm2::lp_dispatcher::{DispatcherContext, LpEvents}; | ||
| use crate::mm2::lp_network::subscribe_to_topic; | ||
| use crate::mm2::lp_ordermatch::{MakerOrderBuilder, OrderConfirmationsSettings}; | ||
| use crate::mm2::lp_swap::{broadcast_transaction_message, tx_helper_topic}; | ||
| use crate::mm2::MM_VERSION; | ||
| use bigdecimal::BigDecimal; | ||
| use bitcrypto::dhash160; | ||
|
|
@@ -680,6 +681,13 @@ impl MakerSwap { | |
| }, | ||
| }; | ||
|
|
||
| broadcast_transaction_message( | ||
| &self.ctx, | ||
| tx_helper_topic(self.maker_coin.ticker()), | ||
| transaction.tx_hex(), | ||
| &self.p2p_privkey, | ||
| ); | ||
|
|
||
| let tx_hash = transaction.tx_hash(); | ||
| log!({ "Maker payment tx {:02x}", tx_hash }); | ||
|
|
||
|
|
@@ -853,6 +861,13 @@ impl MakerSwap { | |
| }, | ||
| }; | ||
|
|
||
| broadcast_transaction_message( | ||
| &self.ctx, | ||
| tx_helper_topic(self.taker_coin.ticker()), | ||
| transaction.tx_hex(), | ||
| &self.p2p_privkey, | ||
| ); | ||
|
|
||
| let tx_hash = transaction.tx_hash(); | ||
| log!({ "Taker payment spend tx {:02x}", tx_hash }); | ||
| let tx_ident = TransactionIdentifier { | ||
|
|
@@ -925,6 +940,14 @@ impl MakerSwap { | |
| ])) | ||
| }, | ||
| }; | ||
|
|
||
| broadcast_transaction_message( | ||
| &self.ctx, | ||
| tx_helper_topic(self.maker_coin.ticker()), | ||
| transaction.tx_hex(), | ||
| &self.p2p_privkey, | ||
| ); | ||
|
|
||
| let tx_hash = transaction.tx_hash(); | ||
| log!({ "Maker payment refund tx {:02x}", tx_hash }); | ||
| let tx_ident = TransactionIdentifier { | ||
|
|
@@ -1143,6 +1166,14 @@ impl MakerSwap { | |
| Ok(Some(FoundSwapTxSpend::Spent(_))) => { | ||
| log!("Warning: MakerPayment spent, but TakerPayment is not yet. Trying to spend TakerPayment"); | ||
| let transaction = try_s!(try_spend_taker_payment(self, &secret_hash.0).await); | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One question to the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I couldn't comment on this snippet: |
||
| broadcast_transaction_message( | ||
| &self.ctx, | ||
| tx_helper_topic(self.taker_coin.ticker()), | ||
| transaction.tx_hex(), | ||
| &self.p2p_privkey, | ||
| ); | ||
|
|
||
| Ok(RecoveredSwap { | ||
| action: RecoveredSwapAction::SpentOtherPayment, | ||
| coin: self.taker_coin.ticker().to_string(), | ||
|
|
@@ -1178,6 +1209,13 @@ impl MakerSwap { | |
| .await | ||
| ); | ||
|
|
||
| broadcast_transaction_message( | ||
| &self.ctx, | ||
| tx_helper_topic(self.maker_coin.ticker()), | ||
| transaction.tx_hex(), | ||
| &self.p2p_privkey, | ||
| ); | ||
|
sergeyboyko0791 marked this conversation as resolved.
Outdated
|
||
|
|
||
| Ok(RecoveredSwap { | ||
| action: RecoveredSwapAction::RefundedMyPayment, | ||
| coin: self.maker_coin.ticker().to_string(), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.