hsd icon indicating copy to clipboard operation
hsd copied to clipboard

MTX.fund - Fixes

Open nodech opened this issue 3 years ago • 6 comments

This is alternative implementation of #639 that solves issue in the CoinSelector.

Separate existing and preferred inputs:

  • existing are the inputs that are present in the mtx.
  • preferred now refers to inputs passed by options.inputs.
  • Use CoinView to resolve coins.

Closes #639

nodech avatar Dec 03 '21 12:12 nodech

Test is just repeat of the matrix, it can be rewritten and shortened as a function..

nodech avatar Dec 03 '21 17:12 nodech

Pull Request Test Coverage Report for Build 1957546736

  • 60 of 61 (98.36%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-14.6%) to 62.844%

Changes Missing Coverage Covered Lines Changed/Added Lines %
lib/primitives/mtx.js 60 61 98.36%
<!-- Total: 60 61
Totals Coverage Status
Change from base Build 1947977808: -14.6%
Covered Lines: 21401
Relevant Lines: 31870

💛 - Coveralls

coveralls avatar Dec 03 '21 17:12 coveralls

Another thing I noticed is that in the worst case scenario, we will loop through this.coins twice and then iterate through a third time to fill the remaining inputs -- do you think it makes any sense to merge the existing & preferred loops? This will also get a lot better when we refactor txdb and not pull ALL COINS out for every tx...

pinheadmz avatar Jan 02 '22 19:01 pinheadmz

The anyone can renew test can also be updated:

https://github.com/handshake-org/hsd/blob/06aabfffe6a26b9c5c1417d80691a8e943a48f1e/test/anyone-can-renew-test.js#L309-L312

pinheadmz avatar Jan 02 '22 19:01 pinheadmz

@nodech checking in on this?

pinheadmz avatar Mar 01 '22 16:03 pinheadmz

One thing that users will have to consider with these changes is that, coinview should always be supplied with coin information when using preferred inputs and existing inputs. If you don't add coins to the coinview, the code will try to fill them in from the coin list it gets, but if the coin list is big that will hit the performance. - That feature is there to help users just in case.

As for double spend question: It's not job of the CoinSelector to resolve double spents that happen because of the existing and preferred inputs. The coinselector itself wont double spend the coins if they are correctly applied to the coinview.

nodech avatar Mar 09 '22 13:03 nodech