mimblewimble / grin-wallet

Grin Wallet
Apache License 2.0
183 stars 133 forks source link

Wrong amount on repeated transaction creation after cancel on pay #706

Closed ardocrat closed 4 months ago

ardocrat commented 4 months ago

Wallet is increasing amount of new created tx after previous cancel for value of requested amount. It also increases it with every attempt for value of previous amount + requested amount.

Reproduce:

# Put invoice from receiver
grin-wallet pay

# See tx at list
grin-wallet txs

# Cancel created tx
grin-wallet cancel -t  

# Put same invoice from receiver
grin-wallet pay

# Amount increased
grin-wallet txs
Anynomouss commented 4 months ago

Quite interesting to see what bug causes to increase the amount with v numbers_of_tries. Perhaps each times the same output is created with a new key and retrieved double since it links to the same input. If that is the case, probably also double change outputs are created. Of-course this would make the transaction invalid since trying to spend an output two times the same time would mean sum(valuesH)!=0, meaning the kernel excess will not be valid pub-key of G. Or each time a new UTXO is used as input, which would simply double the amount each time but would create a valid transaction which is more dangerous for users.