mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 10:22:23 +00:00
parent
61a5976368
commit
f7a0ad47e1
2 changed files with 14 additions and 4 deletions
|
|
@ -48,6 +48,7 @@ type TransactOpts struct {
|
||||||
From common.Address // Ethereum account to send the transaction from
|
From common.Address // Ethereum account to send the transaction from
|
||||||
Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state)
|
Nonce *big.Int // Nonce to use for the transaction execution (nil = use pending state)
|
||||||
Signer SignerFn // Method to use for signing the transaction (mandatory)
|
Signer SignerFn // Method to use for signing the transaction (mandatory)
|
||||||
|
ChainId *big.Int // Chain id to use for signing the transaction (nil = use Homestead signer)
|
||||||
|
|
||||||
Value *big.Int // Funds to transfer along along the transaction (nil = 0 = no funds)
|
Value *big.Int // Funds to transfer along along the transaction (nil = 0 = no funds)
|
||||||
GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle)
|
GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle)
|
||||||
|
|
@ -234,7 +235,14 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
|
||||||
if opts.Signer == nil {
|
if opts.Signer == nil {
|
||||||
return nil, errors.New("no signer to authorize the transaction with")
|
return nil, errors.New("no signer to authorize the transaction with")
|
||||||
}
|
}
|
||||||
signedTx, err := opts.Signer(types.HomesteadSigner{}, opts.From, rawTx)
|
var signer types.Signer
|
||||||
|
if opts.ChainId == nil {
|
||||||
|
signer = types.HomesteadSigner{}
|
||||||
|
} else {
|
||||||
|
signer = types.NewEIP155Signer(opts.ChainId)
|
||||||
|
}
|
||||||
|
signedTx, err := opts.Signer(signer, opts.From, rawTx)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,7 @@ type TransactOpts struct {
|
||||||
|
|
||||||
func (opts *TransactOpts) GetFrom() *Address { return &Address{opts.opts.From} }
|
func (opts *TransactOpts) GetFrom() *Address { return &Address{opts.opts.From} }
|
||||||
func (opts *TransactOpts) GetNonce() int64 { return opts.opts.Nonce.Int64() }
|
func (opts *TransactOpts) GetNonce() int64 { return opts.opts.Nonce.Int64() }
|
||||||
|
func (opts *TransactOpts) GetChainId() *BigInt { return &BigInt{opts.opts.ChainId} }
|
||||||
func (opts *TransactOpts) GetValue() *BigInt { return &BigInt{opts.opts.Value} }
|
func (opts *TransactOpts) GetValue() *BigInt { return &BigInt{opts.opts.Value} }
|
||||||
func (opts *TransactOpts) GetGasPrice() *BigInt { return &BigInt{opts.opts.GasPrice} }
|
func (opts *TransactOpts) GetGasPrice() *BigInt { return &BigInt{opts.opts.GasPrice} }
|
||||||
func (opts *TransactOpts) GetGasLimit() int64 { return int64(opts.opts.GasLimit) }
|
func (opts *TransactOpts) GetGasLimit() int64 { return int64(opts.opts.GasLimit) }
|
||||||
|
|
@ -97,6 +98,7 @@ func (opts *TransactOpts) SetSigner(s Signer) {
|
||||||
return sig.tx, nil
|
return sig.tx, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
func (opts *TransactOpts) SetChainId(chainId *BigInt) { opts.opts.ChainId = chainId.bigint }
|
||||||
func (opts *TransactOpts) SetValue(value *BigInt) { opts.opts.Value = value.bigint }
|
func (opts *TransactOpts) SetValue(value *BigInt) { opts.opts.Value = value.bigint }
|
||||||
func (opts *TransactOpts) SetGasPrice(price *BigInt) { opts.opts.GasPrice = price.bigint }
|
func (opts *TransactOpts) SetGasPrice(price *BigInt) { opts.opts.GasPrice = price.bigint }
|
||||||
func (opts *TransactOpts) SetGasLimit(limit int64) { opts.opts.GasLimit = uint64(limit) }
|
func (opts *TransactOpts) SetGasLimit(limit int64) { opts.opts.GasLimit = uint64(limit) }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue