Skip to content

relaypriority calculation error #8334

@maiiz

Description

@maiiz

relaypriority calculation error

CCoinsViewCache::GetPriority has an overflow bug that affects the relaypriority calculation.
The way the arithmetic works in that function is

dResult += coins->vout[txin.prevout.n].nValue * (nHeight-coins->nHeight); 

the nValue variable type is int64_t, and the int64_t max value is 9223372036854775807
for example

nValue value  is 40000000000000
(nHeight->coins - nHeight )value is 300000 
40000000000000 * 300000 > 9223372036854775807 

so the dResult will be negative number!
and the AllowFree function will return False, and the high priority transaction with low fee will be reject by node with error insufficient priority!

I found this bug when I send a transaction with rpc api sendrawtransaction,i debug the source code find it.

and int64_t convert double also will loss accuracy!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions