def OnBtnClick(self, event): identifier = event.GetEventObject().id if identifier == JOIN_NETWORK: if self.type == "m": self.node = Miner.new(("localhost", int(sys.argv[1]))) elif self.type == "s": self.node = SPVClient.new(("localhost", int(sys.argv[1]))) elif self.type == "f": self.node = SelfishMiner.new(('localhost', int(sys.argv[1]))) elif identifier == START_MINE: self.node.mine() time.sleep(2) self.balance_value.SetLabel( str(self.node.get_own_balance()) + " ") elif identifier == GET_HEADER: self.node.get_blk_headers() elif identifier == UPDATE_BAL: if self.type == "s": balance = self.node.request_balance() self.balance_value.SetLabel(str(balance) + " ") elif self.type == "m" or self.type == "f": self.balance_value.SetLabel( str(self.node.get_own_balance()) + " ") elif identifier == VERIFY_TXN: txn_no = self.txn_no.GetValue() if txn_no >= 1: tx_json = self.node.interested_txn[txn_no - 1] self.node.log(f"<<<Interested Transaction: {tx_json} >>>") time.sleep(5) if tx_json is not None: self.node.verify_user_transaction(tx_json) else: self.node.log("No interested transaction selected") elif identifier == MAKE_TXN: receiver_port = self.to_field.GetValue() receiver_node = self.node.find_peer_by_addr( ("localhost", int(receiver_port))) print(f"receiver node = {receiver_node}") receiver_pubkey = receiver_node["pubkey"] print(f"found receiver pubkey = {receiver_pubkey}") self.node.make_transaction(receiver=receiver_pubkey, amount=float(self.amt_field.GetValue())) if self.type == "s": self.txn_no.SetMax(len(self.node.interested_txn)) elif identifier == SETUP_DS: self.node.setup_ds_attack() elif identifier == START_DS: self.node.ds_mine() elif identifier == RESEND_ATTACK: txn_no = self.txn_no.GetValue() if txn_no >= 1: tx_json = self.node.interested_txn[txn_no - 1] self.node.log(f"<<<Interested Transaction: {tx_json} >>>") time.sleep(5) if tx_json is not None: self.node.tx_resend_attack(tx_json) else: self.node.log("No interested transaction selected")