commerceblock / mercurylayer

A Blinded implementation of mercury statechains
53 stars 9 forks source link

Multiple deposit transactions #21

Open tomt1664 opened 5 months ago

tomt1664 commented 5 months ago

Only one tx can be sent per address.

If the client detects multiple UTXOs per address, then the client should prevent transfers.

Client should enable the withdrawal of multiple UTXOs for the same address.

tomt1664 commented 4 months ago

The wallet should handle multiple deposits in the same way as the previous version.

This is what happens:

User generates deposit address. User pays to the deposit address with a transaction. This UTXO is picked up by the wallet (via Electrum server) and the TxID is set. Coin is confirmed in wallet.

User then sends a second transaction to the same address (i.e. the same shared mercury layer key). The wallet ignores this - it is not waiting for a tx to this address as the coin is already confirmed. So the wallet is currently unaware.

If the user now sends the first coin to someone else, there is no way for them to recover the second.

The coin should have an option/button to check for any other UTXOs paid to the same deposit address. If there are any, then the initial coin should be labeled DUPLICATED status. Once in this status, it cannot be sent (attempting send should show error). It CAN be withdrawn.

Any other UTXOs for this address found, should create new statecoin objects, with the same properties as the initial coin, but labeled DUPLICATE status. These also cannot be sent. But can be withdrawn after the first coin. The server key is not updated, so any number of signatures can be generated on the same shared key.

tomt1664 commented 4 months ago

See: https://github.com/layer2tech/mercury-wallet/blob/2eccf6ce0acecd81f74f1b4e83ced267aa29fba5/src/wallet/wallet.ts#L2244