Beispiel #1
0
 def test_restoring_wallet_with_manual_delete(self, mock_write):
     w = restore_wallet_from_text(
         "hint shock chair puzzle shock traffic drastic note dinosaur mention suggest sweet",
         path='if_this_exists_mocking_failed_648151893',
         gap_limit=5)['wallet']
     # txn A is an external incoming txn funding the wallet
     txA = Transaction(self.transactions[
         "0cce62d61ec87ad3e391e8cd752df62e0c952ce45f52885d6d10988e02794060"]
                       )
     w.add_transaction(txA.txid(), txA)
     # txn B is an outgoing payment to an external address
     txB = Transaction(self.transactions[
         "e7f4e47f41421e37a8600b6350befd586f30db60a88d0992d54df280498f0968"]
                       )
     w.add_transaction(txB.txid(), txB)
     # now the user manually deletes txn B to attempt the double spend
     # txn C is double-spending txn B, to a wallet address
     # rationale1: user might do this with opt-in RBF transactions
     # rationale2: this might be a local transaction, in which case the GUI even allows it
     w.remove_transaction(txB)
     txC = Transaction(self.transactions[
         "a04328fbc9f28268378a8b9cf103db21ca7d673bf1cc7fa4d61b6a7265f07a6b"]
                       )
     w.add_transaction(txC.txid(), txC)
     self.assertEqual(83500163, sum(w.get_balance()))
 def test_dsa_msg(self):
     msg = AxeDsaMsg.from_hex(DSA_MSG)
     assert msg.nDenom == 2
     assert type(msg.txCollateral) == str
     tx = Transaction(msg.txCollateral)
     assert type(tx) == Transaction
     assert bh2u(msg.serialize()) == DSA_MSG
 def test_dsi_msg(self):
     msg = AxeDsiMsg.from_hex(DSI_MSG)
     assert len(msg.vecTxDSIn) == 2
     for txin in msg.vecTxDSIn:
         assert type(txin) == CTxIn
     assert type(msg.txCollateral) == str
     tx = Transaction(msg.txCollateral)
     assert type(tx) == Transaction
     assert len(msg.vecTxDSOut) == 2
     for txout in msg.vecTxDSOut:
         assert type(txout) == CTxOut
     assert bh2u(msg.serialize()) == DSI_MSG
Beispiel #4
0
 def test_restoring_wallet_without_manual_delete(self, mock_write):
     w = restore_wallet_from_text(
         "hint shock chair puzzle shock traffic drastic note dinosaur mention suggest sweet",
         path='if_this_exists_mocking_failed_648151893',
         gap_limit=5)['wallet']
     for txid in self.transactions:
         tx = Transaction(self.transactions[txid])
         w.add_transaction(tx.txid(), tx)
     # txn A is an external incoming txn funding the wallet
     # txn B is an outgoing payment to an external address
     # txn C is double-spending txn B, to a wallet address
     self.assertEqual(83500163, sum(w.get_balance()))
Beispiel #5
0
 def do_paste(self):
     data = self.app._clipboard.paste()
     if not data:
         self.app.show_info(_("Clipboard is empty"))
         return
     # try to decode as transaction
     try:
         raw_tx = tx_from_str(data)
         tx = Transaction(raw_tx)
         tx.deserialize()
     except:
         tx = None
     if tx:
         self.app.tx_dialog(tx)
         return
     # try to decode as URI/address
     self.set_URI(data)
Beispiel #6
0
 def on_qr(self, data):
     from electrum_axe.bitcoin import base_decode, is_address
     data = data.strip()
     if is_address(data):
         self.set_URI(data)
         return
     if data.startswith('axe:'):
         self.set_URI(data)
         return
     # try to decode transaction
     from electrum_axe.transaction import Transaction
     try:
         text = base_decode(data, None, base=43).encode('hex')
         tx = Transaction(text)
         tx.deserialize()
     except:
         tx = None
     if tx:
         self.tx_dialog(tx)
         return
     # show error
     self.show_error("Unable to decode QR data")
Beispiel #7
0
 def test_verify_ok_t_tx(self):
     """Actually mined 64 byte tx should not raise."""
     t_tx = Transaction(VALID_64_BYTE_TX)
     t_tx_hash = t_tx.txid()
     self.assertEqual(MERKLE_ROOT, SPV.hash_merkle_root(MERKLE_BRANCH, t_tx_hash, 3))