From 28bae15e5375d57e71f7cce2da509e89cfb15e94 Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Thu, 26 Oct 2017 18:57:11 +0100 Subject: [PATCH] accounts/abi: Provide DoNotSend flag in TransactOpts --- accounts/abi/bind/base.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/accounts/abi/bind/base.go b/accounts/abi/bind/base.go index b40bd65e80..c6e56a63dd 100644 --- a/accounts/abi/bind/base.go +++ b/accounts/abi/bind/base.go @@ -52,7 +52,8 @@ type TransactOpts struct { GasPrice *big.Int // Gas price to use for the transaction execution (nil = gas price oracle) 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 @@ -219,8 +220,10 @@ func (c *BoundContract) transact(opts *TransactOpts, contract *common.Address, i if err != nil { return nil, err } - if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil { - return nil, err + if !opts.DoNotSend { + if err := c.transactor.SendTransaction(ensureContext(opts.Context), signedTx); err != nil { + return nil, err + } } return signedTx, nil }