From fec5aeb010d21f736193000a0e89a0bc6c1eb54b Mon Sep 17 00:00:00 2001 From: Mariano Sorgente <3069354+mariano54@users.noreply.github.com> Date: Tue, 15 Sep 2020 01:49:24 +0900 Subject: [PATCH] Get UI working --- electron-react/src/modules/incoming_api.js | 1 - electron-react/src/util/transaction_result.js | 43 ++++++++++--------- src/cmds/wallet.py | 2 +- src/wallet/wallet_state_manager.py | 2 +- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/electron-react/src/modules/incoming_api.js b/electron-react/src/modules/incoming_api.js index c255a2ab..b985af0e 100644 --- a/electron-react/src/modules/incoming_api.js +++ b/electron-react/src/modules/incoming_api.js @@ -245,7 +245,6 @@ export const incomingReducer = (state = { ...initial_state }, action) => { return { ...state }; } if (command === "state_changed" && data.state === "tx_update") { - console.log("Got tx update!", data); const id = data.wallet_id; wallets = state.wallets; wallet = wallets[parseInt(id)]; diff --git a/electron-react/src/util/transaction_result.js b/electron-react/src/util/transaction_result.js index a12fc4e0..d4c06f76 100644 --- a/electron-react/src/util/transaction_result.js +++ b/electron-react/src/util/transaction_result.js @@ -7,32 +7,35 @@ export const mempool_inclusion_status = { export const get_transaction_result = (transaction) => { let success = true; let message = ""; - if (!transaction) { + if (!transaction || transaction.transaction.sent_to.length === 0) { return { message, success } } - for (let full_node_response of transaction.transaction.sent_to) { - console.log("full node response", full_node_response); + // At least one node has accepted our transaction + for (let full_node_response of transaction.transaction.sent_to) { + if (full_node_response[1] === mempool_inclusion_status["SUCCESS"]) { + return { + "message": "Transaction has successfully been sent to a full node and included in the mempool.", + success: true, + }; } + } + // At least one node has accepted our transaction as pending + for (let full_node_response of transaction.transaction.sent_to) { + if (full_node_response[1] === mempool_inclusion_status["PENDING"]) { + return { + "message": ("Transaction has sent to a full node and is pending inclusion into the mempool. " + full_node_response[2]), + success: true, + }; + } + } -// if (send_transaction_result) { -// if (send_transaction_result.status === "SUCCESS") { -// result_message = -// "Transaction has successfully been sent to a full node and included in the mempool."; -// } else if (send_transaction_result.status === "PENDING") { -// result_message = -// "Transaction has sent to a full node and is pending inclusion into the mempool. " + -// send_transaction_result.reason; -// } else { -// result_message = "Transaction failed. " + send_transaction_result.reason; -// result_class = classes.resultFailure; -// } -// } - return { - message, - success - } + // No nodes have accepted our transaction, so display the error message of the first + return { + "message": transaction.transaction.sent_to[0][2], + "success": false, + }; } diff --git a/src/cmds/wallet.py b/src/cmds/wallet.py index c9977e6e..3af8305e 100644 --- a/src/cmds/wallet.py +++ b/src/cmds/wallet.py @@ -75,7 +75,7 @@ async def wallet_loop(wallet_client): print(f"{i+1}) {fp}") val = None while val is None: - val = input("Enter number to pick press q to quite: ") + val = input("Enter a number to pick or q to quit: ") if val == "q": return if not val.isdigit(): diff --git a/src/wallet/wallet_state_manager.py b/src/wallet/wallet_state_manager.py index f7da4974..c210b9f4 100644 --- a/src/wallet/wallet_state_manager.py +++ b/src/wallet/wallet_state_manager.py @@ -324,7 +324,7 @@ class WalletStateManager: break puzzlehash: bytes32 = puzzle.get_tree_hash() self.log.info( - f"Puzzle at index {index} with {wallet_id} puzzle hash {puzzlehash.hex()}" + f"Puzzle at index {index} wallet ID {wallet_id} puzzle hash {puzzlehash.hex()}" ) derivation_paths.append( DerivationRecord(