在测试eth.pendingTransactions时,无法获取到数据,查看代码(Github Code)

// PendingTransactions returns the transactions that are in the transaction pool
// and have a from address that is one of the accounts this node manages.
func (s *PublicTransactionPoolAPI) PendingTransactions() ([]*RPCTransaction, error) {
    pending, err := s.b.GetPoolTransactions()
    if err != nil {
        return nil, err
    }
    accounts := make(map[common.Address]struct{})
    for _, wallet := range s.b.AccountManager().Wallets() {
        for _, account := range wallet.Accounts() {
            accounts[account.Address] = struct{}{}
        }
    }
    curHeader := s.b.CurrentHeader()
    transactions := make([]*RPCTransaction, 0, len(pending))
    for _, tx := range pending {
        from, _ := types.Sender(s.signer, tx)
        if _, exists := accounts[from]; exists {
            transactions = append(transactions, newRPCPendingTransaction(tx, curHeader, s.b.ChainConfig()))
        }
    }
    return transactions, nil
}

原因

由于查询eth.pendingTransactions性能消耗较大,所以代码加了一层限制,必须查询当前交易的签名者地址加到当前节点地址中

./geth attach ipc:./data/geth.ipc
personal.importRawKey("e9bc9ae610535。。。。f4f49c025cc","passwrod..")

注意

由于当前私钥可能被外网猜测,所以当前查询节点不能对外提供RPC服务,只能内网被业务服务调用。并做好节点访问权限安全防范

参考

https://github.com/ethereum/go-ethereum/issues/21138