OpenBazaar / multiwallet

API based multi-cryptocurrency wallet
MIT License
72 stars 41 forks source link

Rebroadcasting already confirmed transactions #78

Closed placer14 closed 5 years ago

placer14 commented 5 years ago

Found that certain transactions are being rebroadcast despite already being confirmed on the blockchain. This appears in the logs as:

12:27:44.108 [INFO] [WalletService/processIncomingBlock] received new Zcash block at height 505543: <block hash>
12:27:44.109 [DEBUG] [WalletService/getStoredAddresses] preparing stored addresses
12:27:44.117 [DEBUG] [WalletService/processIncomingBlock] broadcasting unconfirmed txid <txid>
12:27:44.117 [DEBUG] [pool/func1] (https://zec.blockbook.api.openbazaar.org/api) request transaction data, txid: <txid>
12:27:44.274 [DEBUG] [pool/func1] (https://zec.blockbook.api.openbazaar.org/api) broadcasting transaction
12:27:44.420 [ERROR] [client/doRequest] not ok (GET https://zec.blockbook.api.openbazaar.org/api/sendtx/<txpayload>): responded 400 Bad Request
12:27:44.420 [DEBUG] [client/doRequest] not ok response body (GET https://zec.blockbook.api.openbazaar.org/api/sendtx/<txpayload>
12:27:44.420 [ERROR] [pool/executeRequest] unretryable error: error broadcasting tx: status not ok: 400 Bad Request
12:27:44.420 [ERROR] [WalletService/func1] broadcasting unconfirmed utxo: error broadcasting tx: status not ok: 400 Bad Request
12:28:04.180 [DEBUG] [service/handlePing] Received PING message from PEERID

This behavior repeats on each new block. The WalletService.processIncomingBlock method updates the transaction to ensure it is up to date, but we should prevent unnecessary broadcasts from occurring.