accounts/abi: Provide DoNotSend flag in TransactOpts

This commit is contained in:
Jim McDonald 2017-10-26 18:57:11 +01:00
parent 0095531a58
commit 28bae15e53

View file

@ -53,6 +53,7 @@ type TransactOpts struct {
GasLimit *big.Int // Gas limit to set for the transaction execution (nil = estimate + 10%) GasLimit *big.Int // Gas limit to set for the transaction execution (nil = estimate + 10%)
Context context.Context // Network context to support cancellation and timeouts (nil = no timeout) Context context.Context // Network context to support cancellation and timeouts (nil = no timeout)
DoNotSend bool // Do not send the transaction; used for dry runs and offline transaction generation
} }
// BoundContract is the base wrapper object that reflects a contract on the // BoundContract is the base wrapper object that reflects a contract on the
@ -219,9 +220,11 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !opts.DoNotSend {
if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil { if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil {
return nil, err return nil, err
} }
}
return signedTx, nil return signedTx, nil
} }