Skip to content

Transactions inserted with Wallet::insert_tx will be replaced by the wallet when creating a new tx. #1642

@evanlinjin

Description

@evanlinjin

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

  1. 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.
  2. 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdiscussionThere's still a discussion ongoing

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions