[bug] utxo outbound mismatch due to float addition
A couple DOGE outbounds have become pseduo-stuck after being successfully signed, sent, and then incorrectly slashed for not matching the expected outbound item. @ursa9r noticed an off by 1 in the values expected vs. signed (see example tx details below) which causes the mismatch.
This is due to a floating point issue. btcd
returns utxo amounts as floats instead of ints. We currently sum the float amounts, then use btcutil
to convert the total to an int. Solution is to convert each individual amount to int and sum those instead. See: https://gitlab.com/thorchain/thornode/-/blob/develop/bifrost/pkg/chainclients/utxo/signer_internal.go#L265-267
$ http https://thornode-v1.ninerealms.com/thorchain/tx/details/1AEBC1E0341C76C6AAA986BE281B588FBB6B8E2C3BE42BCA94F9B3ECEA6951A7 | jq '(.actions[0].coin.amount|tonumber)+(.actions[0].max_gas[0].amount|tonumber)'
79367763495
$ http https://thornode-v1.ninerealms.com/thorchain/tx/details/90348B699DF3832F903EF1D8EF248E824EF659EC442CABA68988CD8690CD03CD | jq '(.tx.tx.coins[0].amount|tonumber)+(.tx.tx.gas[0].amount|tonumber)'
79367763494
Bifrost logs:
01/02 00:05:46 EST INF utxo/signer_internal.go:353 > max gas is: [750000000 DOGE.DOGE], however only: 312750000 is required, gap: 437250000 goes to customer chain=DOGE service=bifrost
01/02 00:05:46 EST INF utxo/signer_internal.go:380 > total: 2382717816825268, to customer: 79055013495, gas: 312750000 chain=DOGE service=bifrost
Total VIN sats computed by Bifrost is 1 sat higher than actual: https://dogechain.info/tx/90348b699df3832f903ef1d8ef248e824ef659ec442caba68988cd8690cd03cd