Open dan-da opened 3 days ago
hmm, digging into the code, I don't immediately see how to achieve unconfirmed tx chaining. Tx validation requires that the PrimitiveWitness have one mutator-set memership proof per input. But input utxos in the mempool are represented as RemovalRecord, with no such membership proof.
I am not certain if it is possible with Neptune's design or not. a question for @aszepieniec.
Even if unconfirmed tx chaining is not presently achievable, create_transaction() can still avoid adding any input that is already in the mempool. That would prevent the input re-use.
Presently create_transaction() will re-use the same inputs when it is called multiple times in the same block.
eg, consider this loop:
What happens is that 5 tx get created that all spend the same input.
(but Mempool::insert() de-dups them into just one tx)
This is because create_transaction() calls
WalletState::allocate_sufficient_input_funds_from_lock()
which fetches unspent utxos that are valid as of tip block. It does not consider utxos in the mempool at all.This means that:
Fixing this will require that create_transaction() inspects the utxos in the mempool.