helium/blockchain-core

FULL $10 CHARGE on FIRST assert_location_v2 issue when using CLI tool

rsnodgrass opened this issue · 4 comments

See helium/helium-wallet-rs#243

More details to follow. Looking at assert_location_v2 Erlang to find logic where the first assert is waived. I believe this checks if the fee is $10 (but it can be $10.55 in some cases, for example where the assert occurs with antenna height/gain). The Helium app never adds height/gain into the same transaction...but the CLI tools can. It appears this causes the full $10.55 to be charged to the Hotspot Owner even on the first assert (it should be 0 DC in this case as well).

I believe the offending code is actually either here:

https://github.com/helium/blockchain-core/blob/master/src/transactions/v2/blockchain_txn_assert_location_v2.erl#L187

Or L173 of assert_location_v1 (which it appears assert_location_v2 can end up calling in certain circumstances when calculating assert fees):

https://github.com/helium/blockchain-core/blob/master/src/transactions/v1/blockchain_txn_assert_location_v1.erl#L173

The above code doesn't charge the fee if the Payer is undefined. However, when you also assert the antenna gain/height the Payer becomes the Hotspot owner...and then the entire amount is charged to the Hotspot Owner.

As an example, here is a CLI assert of a BRAND NEW hotspot, and even WITHOUT including the gain or height (using the default), you can see that 1,000,000 DC was charged as the staking fee.

Password: [hidden]
+------------------+------------------------------------------------------+
| Key              | Value                                                |
+------------------+------------------------------------------------------+
| Address          | XXXXXXXXXXX |
+------------------+------------------------------------------------------+
| Location         | xxxxxxxxxxxx                                      |
+------------------+------------------------------------------------------+
| Payer            | XXXXXXXXXXX  |
+------------------+------------------------------------------------------+
| Nonce            | 1                                                    |
+------------------+------------------------------------------------------+
| Fee (DC)         | 55000                                                |
+------------------+------------------------------------------------------+
| Staking Fee (DC) | 1000000                                              |
+------------------+------------------------------------------------------+
| Gain (dBi)       | 1.2                                                  |
+------------------+------------------------------------------------------+
| Elevation        | 0                                                    |
+------------------+------------------------------------------------------+
| Hash             |  XXXXXXXX          |
+------------------+------------------------------------------------------+

did you specify the --onboarding flag to use the DeWi onboarding server to get the free first assert?

Aha! I did not know there was a special flag. Thanks Marc.