ethereum / wiki

The Ethereum Wiki
https://www.ethereum.org
14.75k stars 2.57k forks source link

how to compare the from's funds when send tx #623

Closed kazaff closed 6 years ago

kazaff commented 6 years ago

Hi there,

I wonder that when we create a transaction and send it with eth_sendRawTransaction RPC method, how the Geth can make sure the error(Insufficient funds for gas * price + value) was happened?

I mean i know the source code in here:

        // Transactor should have enough funds to cover the costs
    // cost == V + GP * GL
    if b := currentState.GetBalance(from); b.Cmp(tx.Cost()) < 0 {
        return core.ErrInsufficientFunds
    }

But I would like to know the detail about currentState.GetBalance(from) like:

DO the from address's balance include any transaction in pending? or just only contain completed transaction?

Thanks in advance!!

minimapletinytools commented 6 years ago

The balance is computed from the current chain head and does not include pending transactions.

jamesray1 commented 6 years ago

Please see https://github.com/ethereum/wiki/blob/master/ISSUE_TEMPLATE.md but looks like your question has been answered.