trezor-firmware
trezor-firmware copied to clipboard
Fractional fee rates are incorrectly displayed with latest develop version
Describe the bug Fractional fee rates are incorrectly displayed with latest develop versions. I was not able to reproduce issue on production versions of firmwares /only final fee is displayed and not fee rate/
Info:
- Suite version: desktop 22.7.3 (8eddb2accd31c78577f276df2e9ecf773d2c3c17)
- Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) TrezorSuite/22.7.3 Chrome/100.0.4896.160 Electron/18.3.5 Safari/537.36
- OS: MacIntel
- Screen: 1680x1050
- Device: model T 2.5.2 regular (revision 426eae4dfcb853041419030bbb104cc2bbf6629f)
- Transport: bridge 2.0.31
To Reproduce Steps to reproduce the behavior:
- Navigate to Send dialogue
- Enter custom fee with fractions
- Compare fee rate in Suite and on device during TX signing
Screenshots

Can confirm this on my machine locally suite 4e981fe1a7220d540a2d253edeabd682e4eba742 firmware 426eae4dfcb853041419030bbb104cc2bbf6629f

Suite send form inputs
[
{
"address_n": [
2147483732,
2147483649,
2147483650,
0,
0
],
"prev_index": 0,
"prev_hash": "937fd4b14deb26622602ae8efdbe9f7c62f71c68d597503d84252a3ab20eff9d",
"script_type": "SPENDWITNESS",
"amount": "200000",
"sequence": 4294967293
}
]
and outputs
[
{
"address": "tb1q5za9jzkg5g4flv7a3afgmrwzvswvutza7r5cmv",
"amount": "181124",
"script_type": "PAYTOADDRESS"
}
]
the same transaction in blockbok https://tbtc1.trezor.io/tx/2562027380d996c3502a76038adde9082ee6e7da3021ebb661fde4ebd6baaa51
{
"txid": "2562027380d996c3502a76038adde9082ee6e7da3021ebb661fde4ebd6baaa51",
"hash": "5bc8acad69fd4e6b27a71f1eceaacfab5fe25fdac3de881401e42df6864194ff",
"version": 1,
"size": 192,
"vsize": 110,
"weight": 438,
"locktime": 0,
"vin": [
{
"txid": "937fd4b14deb26622602ae8efdbe9f7c62f71c68d597503d84252a3ab20eff9d",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"3045022100beb2c6af2ab63cdb0240063157afa8d84ec9dfb404ff5eadb9f96a6f3552e41202204c4a6bfd2010d2220becd92e6b60e92f6a1c1a75f3c95e39f3f7063a26225c9201",
"034cff51305dd0113ca4cd3b18d6d94fb69a70f792e5a0b9207145c1549c575463"
],
"sequence": 4294967293
}
],
"vout": [
{
"value": 0.00181124,
"n": 0,
"scriptPubKey": {
"asm": "0 a0ba590ac8a22a9fb3dd8f528d8dc2641cce2c5d",
"desc": "addr(tb1q5za9jzkg5g4flv7a3afgmrwzvswvutza7r5cmv)#nu4q7d2s",
"hex": "0014a0ba590ac8a22a9fb3dd8f528d8dc2641cce2c5d",
"address": "tb1q5za9jzkg5g4flv7a3afgmrwzvswvutza7r5cmv",
"type": "witness_v0_keyhash"
}
}
],
"hex": "010000000001019dff0eb23a2a25843d5097d5681cf7627c9fbefd8eae02266226eb4db1d47f930000000000fdffffff0184c3020000000000160014a0ba590ac8a22a9fb3dd8f528d8dc2641cce2c5d02483045022100beb2c6af2ab63cdb0240063157afa8d84ec9dfb404ff5eadb9f96a6f3552e41202204c4a6bfd2010d2220becd92e6b60e92f6a1c1a75f3c95e39f3f7063a26225c920121034cff51305dd0113ca4cd3b18d6d94fb69a70f792e5a0b9207145c1549c57546300000000"
}
input amount = 200000 output amount = 181124 fee = (input - output) = 18876 vsize = 110 fee rate = 18876 / 110 = 171.6
Doing the same in production suite 8eddb2accd31c78577f276df2e9ecf773d2c3c17 firmware 426eae4dfcb853041419030bbb104cc2bbf6629f
seems to yield the same results
https://tbtc2.trezor.io/tx/c5fcaa8ce74ca520ac9e6bd76b7d8763faf90c2ddde4f19c575797198f4571e1
Trezor uses fractional vsize 109.5, so the fee rate comes out to 18876 / 109.5 = 172.38 Which is correct?
Suite calculates vsize as 110 from here https://github.com/trezor/trezor-suite/blob/f634404cd674c1af56aa5866d161382ca6957ea1/packages/utxo-lib/src/coinselect/utils.ts#L77-L95 (TX_BASE=32) can you spot a bug?
the bug is on firmware side. Suite does the correct thing:
Virtual transaction size is defined as Transaction weight / 4 (rounded up to the next integer).
fw does not do the round-up step.
guess we can move the issue back to fw repo, @bosomt :)
and resolved in #2431
QA NOK
sorry :(
Info:
- Suite version: desktop 22.8.1 (503b472935dec8a9c07aac5eef5ba43f86780a38)
- Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) TrezorSuite/22.8.1 Chrome/100.0.4896.160 Electron/18.3.5 Safari/537.36
- OS: MacIntel
- Screen: 1680x1050
- Device: model T 2.5.3 Universal (revision ef47c262720be8b21671e85d7af68c547ad1955e)
- Transport: bridge 2.0.31
well that's a big difference
can you give us the tx parameters? or the raw signed tx?
tx inputs:
[
{
"address_n": [
2147483732,
2147483649,
2147483648,
0,
0
],
"prev_index": 0,
"prev_hash": "a55a49138d2dbf49f344e3fd3fd7821593c01daec1ab340a845ea328dac2cdd1",
"script_type": "SPENDWITNESS",
"amount": "1198145",
"sequence": 4294967293
}
]
outputs:
[
{
"address": "tb1q59gtxd5g4zzlu4l4u5dg4z00j2qxxsmu9tw9d6",
"amount": "1000",
"script_type": "PAYTOADDRESS"
}
]
raw signed tx (invalid signature):
02000000000101d1cdc2da28a35e840a34abc1ae1dc0931582d73ffde344f349bf2d8d13495aa50000000000fdffffff01e803000000000000160014a150b33688a885fe57f5e51a8a89ef928063437c02473044022060b7cf4bf51fcc9697f08464ecb143688aadf707bf2338baea0455bb3860bf4502207245839d19ae19bad504ce5c0349dd5868133e3ae8c6937dccea1567c963b477012103adc58245cf28406af0ef5cc24b8afba7f1be6c72f279b642d85c48798685f86200000000
an independent library counts vsize as 110 which matches Trezor's fee rate but not Suite's. @mroz22 can you take a look?
110 in suite as well.
In some cases, it could be this issue https://github.com/trezor/trezor-suite/issues/5907
but in this case it does not feel like that because if you have vsize 110 and feeRate 8888.99 it makes up 977788.9 so there is plenty of space to create change output
edit 1:
aha, I see should there be change output, it would be something like 141 bytes and with such a high fee input of 1198145 would not be enough. So this indeed only needs some better UX in suite
QA OK
fixed 🎉 , tested at least 10 fee rates up to 8888.88 or 9999.99 and it always matched /device vs Suite/
Info:
- Suite version: desktop 23.1.0 (38b40ef729793e945c3ad2c1f45e29db49460311)
- Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) TrezorSuite/23.1.0 Chrome/104.0.5112.124 Electron/20.3.5 Safari/537.36
- OS: MacIntel
- Screen: 1440x900
- Device: model T 2.5.4 Universal (revision 305b7fe84d802db7f0826d07a222a886f73732f0)
- Transport: bridge 2.0.32