hsd
hsd copied to clipboard
feat(wallet): sendbid accepts addr to bid to
This change adds the option to (optionally) pick which address will be used to submit a bid.
hsw-rpc sendbid $name $amount $lockup [$address]
Pull Request Test Coverage Report for Build 1957542198
- 14 of 17 (82.35%) changed or added relevant lines in 2 files are covered.
- 1 unchanged line in 1 file lost coverage.
- Overall coverage decreased (-14.7%) to 62.773%
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % |
---|---|---|---|
lib/wallet/wallet.js | 9 | 10 | 90.0% |
lib/wallet/rpc.js | 5 | 7 | 71.43% |
<!-- | Total: | 14 | 17 |
Files with Coverage Reduction | New Missed Lines | % |
---|---|---|
lib/covenants/rules.js | 1 | 69.31% |
<!-- | Total: | 1 |
Totals | |
---|---|
Change from base Build 1947977808: | -14.7% |
Covered Lines: | 21364 |
Relevant Lines: | 31844 |
💛 - Coveralls
Can you explain your use case a bit more? This action is potentially risky since a BID without REVEAL can destroy money, and the wallet may not have the private key for the arbitrary address you are passing to the API call?
the wallet may not have the private key for the arbitrary address you are passing to the API call
If the wallet don't know the address used for BID, it will fail to load its account and won't be able to generate the nonce. https://github.com/handshake-org/hsd/blob/611421d3513e6514e8e6754c7bf21bd9932dcb20/lib/wallet/wallet.js#L1203-L1221
but whats wrong with just using the wallet's next receive address?
https://github.com/handshake-org/hsd/blob/107ed2be9280bb4292d21330e7d1ace62da9a002/lib/wallet/wallet.js#L1694
I'm just wondering if this is so useful we need to change the API and continue to maintain it. (e.g. do we need to add this option to every wallet call? or maybe a bigger custom create-tx endpoint is better suited to cover all similar use-cases?)
I'm not sure what exactly you're up to, but I can also see maybe using the API to create an unsigned BID, then changing the receive address and then signing it -- using hsd as a library or using api calls from the application layer.
If the wallet don't know the address used for BID, it will fail to load its account and won't be able to generate the nonce.
Also I feel like depending on a undefined behavior like generateNonce()
to fail when a bid is made to a non wallet address doesn't feel like that great of a idea, and very confusing for someone who might expect a arbitrary address bid to work.