Describe the bug
When a caller manually inserts a transaction into wallet via Wallet::insert_tx, it is an intuitive assumption that the transaction inserted will not be replaced by a new transaction created with Wallet::build_tx.
However, the current default behavior of Wallet::build_tx replaces the transaction inserted with Wallet::insert_tx since purely inserting a transaction without a last_seen or Anchor to the best chain means that the tx will not be part of the canonical chain.
Thank you @stevenroose for bringing this to my attention. Am I missing anything here?
To Reproduce
Some simple steps for reproducing.
- Create a wallet with a single UTXO.
- Create a tx (
T1) from that wallet and send to foreign address A.
- Insert
T1 into the wallet via Wallet::insert_tx.
- Create another tx (
T2) that sends to foreign address B.
- Compare inputs of A & B. They should not be the same - but they are.
Proposed solutions
- Add another parameter to
insert_tx: last_seen: Option<u64>, and document that we need the last_seen value in order for the tx to be seen in the canonical chain.
- Have wallet keep track of which transactions it has created. We shouldn't be replacing transactions that we create.
I think 1. should be the solution for now. 2. will need more thinking.
Describe the bug
When a caller manually inserts a transaction into wallet via
Wallet::insert_tx, it is an intuitive assumption that the transaction inserted will not be replaced by a new transaction created withWallet::build_tx.However, the current default behavior of
Wallet::build_txreplaces the transaction inserted withWallet::insert_txsince purely inserting a transaction without alast_seenorAnchorto the best chain means that the tx will not be part of the canonical chain.Thank you @stevenroose for bringing this to my attention. Am I missing anything here?
To Reproduce
Some simple steps for reproducing.
T1) from that wallet and send to foreign address A.T1into the wallet viaWallet::insert_tx.T2) that sends to foreign address B.Proposed solutions
insert_tx:last_seen: Option<u64>, and document that we need the last_seen value in order for the tx to be seen in the canonical chain.I think
1.should be the solution for now.2.will need more thinking.