mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
added 3rd party payer fields to transaction
This commit is contained in:
parent
701677b9e1
commit
9b5d31474f
8 changed files with 36 additions and 4 deletions
|
|
@ -756,6 +756,7 @@ func testExternalUI(api *core.SignerAPI) {
|
|||
time.Sleep(delay)
|
||||
expectResponse("showerror", "Did you see the message? [yes/no]", "yes")
|
||||
}
|
||||
/*
|
||||
{ // Sign data test - clique header
|
||||
api.UI.ShowInfo("Please approve the next request for signing a clique header")
|
||||
time.Sleep(delay)
|
||||
|
|
@ -784,6 +785,7 @@ func testExternalUI(api *core.SignerAPI) {
|
|||
_, err = api.SignData(ctx, accounts.MimetypeClique, *addr, hexutil.Encode(cliqueRlp))
|
||||
expectApprove("signdata - clique header", err)
|
||||
}
|
||||
*/
|
||||
{ // Sign data test - typed data
|
||||
api.UI.ShowInfo("Please approve the next request for signing EIP-712 typed data")
|
||||
time.Sleep(delay)
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ import (
|
|||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -149,7 +151,9 @@ func (ethash *Ethash) mine(block *types.Block, id int, seed uint64, abort chan s
|
|||
)
|
||||
if len(block.Transactions()) < 1 {
|
||||
|
||||
log.Info(“No txs”)
|
||||
log.Info("No txs")
|
||||
log.Info("Lel","asd",crypto.VerifySignature([]byte("376fc429acc35e610f75b14bc96242b13623833569a5bb3d72c17be7e51da0bb58e48e2462a59897cead8ab88e78709f9d24fd6ec24d1456f43aae407a8970e4"),
|
||||
[]byte("5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060"),[]byte("cdffeff8feff9cffee15dbeffe5ffdb7ffdbb7f6bfffdcaffbedb74e4f3ff3fa")))
|
||||
return
|
||||
}
|
||||
logger := log.New("miner", id)
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package core
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/consensus"
|
||||
"github.com/ethereum/go-ethereum/core/state"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
|
@ -79,12 +78,18 @@ func (v *BlockValidator) ValidateBody(block *types.Block) error {
|
|||
// otherwise nil and an error is returned.
|
||||
func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateDB, receipts types.Receipts, usedGas uint64) error {
|
||||
header := block.Header()
|
||||
|
||||
if block.GasUsed() != usedGas {
|
||||
return fmt.Errorf("invalid gas used (remote: %d local: %d)", block.GasUsed(), usedGas)
|
||||
}
|
||||
if block.GasUsed() == 0 {
|
||||
|
||||
return fmt.Errorf("krds napiyon bos block bu")
|
||||
}
|
||||
|
||||
//TEST
|
||||
|
||||
//TEST
|
||||
// Validate the received block's bloom with the one derived from the generated receipts.
|
||||
// For valid blocks this should always validate to true.
|
||||
rbloom := types.CreateBloom(receipts)
|
||||
|
|
|
|||
|
|
@ -511,6 +511,14 @@ func (pool *TxPool) local() map[common.Address]types.Transactions {
|
|||
// rules and adheres to some heuristic limits of the local node (price and size).
|
||||
func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
||||
// Heuristic limit, reject transactions over 32KB to prevent DOS attacks
|
||||
|
||||
if tx.Payer != nil {
|
||||
log.Info("pilge", "payer :", tx.Payer())
|
||||
log.Info("pilge", "sender :", tx.Sender())
|
||||
log.Info("pilge", "payer signature :", tx.PayerSig())
|
||||
|
||||
}
|
||||
|
||||
if tx.Size() > 32*1024 {
|
||||
return ErrOversizedData
|
||||
}
|
||||
|
|
@ -526,6 +534,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
|||
// Make sure the transaction is signed properly
|
||||
from, err := types.Sender(pool.signer, tx)
|
||||
if err != nil {
|
||||
log.Info("pilge", "tx", tx)
|
||||
return ErrInvalidSender
|
||||
}
|
||||
// Drop non-local transactions under our own minimal accepted gas price
|
||||
|
|
@ -539,6 +548,7 @@ func (pool *TxPool) validateTx(tx *types.Transaction, local bool) error {
|
|||
}
|
||||
// Transactor should have enough funds to cover the costs
|
||||
// cost == V + GP * GL
|
||||
|
||||
if pool.currentState.GetBalance(from).Cmp(tx.Cost()) < 0 {
|
||||
return ErrInsufficientFunds
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,6 +86,8 @@ type Header struct {
|
|||
Nonce BlockNonce `json:"nonce"`
|
||||
}
|
||||
|
||||
|
||||
|
||||
// field type overrides for gencodec
|
||||
type headerMarshaling struct {
|
||||
Difficulty *hexutil.Big
|
||||
|
|
|
|||
|
|
@ -50,6 +50,10 @@ type txdata struct {
|
|||
Recipient *common.Address `json:"to" rlp:"nil"` // nil means contract creation
|
||||
Amount *big.Int `json:"value" gencodec:"required"`
|
||||
Payload []byte `json:"input" gencodec:"required"`
|
||||
Sender []byte `json:"sender"`
|
||||
Payer []byte `json:"payer"`
|
||||
PayerSig []byte `json:"payerSig"`
|
||||
|
||||
|
||||
// Signature values
|
||||
V *big.Int `json:"v" gencodec:"required"`
|
||||
|
|
@ -178,6 +182,10 @@ func (tx *Transaction) GasPrice() *big.Int { return new(big.Int).Set(tx.data.Pri
|
|||
func (tx *Transaction) Value() *big.Int { return new(big.Int).Set(tx.data.Amount) }
|
||||
func (tx *Transaction) Nonce() uint64 { return tx.data.AccountNonce }
|
||||
func (tx *Transaction) CheckNonce() bool { return true }
|
||||
func (tx *Transaction) Payer() []byte { return common.CopyBytes(tx.data.Payer) }
|
||||
func (tx *Transaction) Sender() []byte { return common.CopyBytes(tx.data.Sender) }
|
||||
func (tx *Transaction) PayerSig() []byte { return common.CopyBytes(tx.data.PayerSig) }
|
||||
|
||||
|
||||
// To returns the recipient address of the transaction.
|
||||
// It returns nil if the transaction is a contract creation.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"config": {
|
||||
"chainId": 12331445,
|
||||
"chainId": 18,
|
||||
"homesteadBlock": 0,
|
||||
"eip150Block": 0,
|
||||
"eip155Block": 0,
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
},
|
||||
"alloc": {
|
||||
"0x2dBc8820de97670590f40Fa4996D177657A2bc9A": {
|
||||
"balance": "1000000"
|
||||
"balance": "100000000000000000000"
|
||||
},
|
||||
"0x8AFdC8c097CF75ebbAAFccA194735Bd77bc50b69": {
|
||||
"balance": "1000000"
|
||||
|
|
|
|||
|
|
@ -6342,6 +6342,7 @@ RequestManager.prototype.send = function (data) {
|
|||
|
||||
var payload = Jsonrpc.toPayload(data.method, data.params);
|
||||
var result = this.provider.send(payload);
|
||||
console.error(result);
|
||||
|
||||
if (!Jsonrpc.isValidResponse(result)) {
|
||||
throw errors.InvalidResponse(result);
|
||||
|
|
|
|||
Loading…
Reference in a new issue