Skip to content

Commit 20bfb62

Browse files
committed
accounts: check fallback and receive before transfer
remove todo
1 parent c3ef6c7 commit 20bfb62

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

accounts/abi/bind/v2/base.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,11 @@ func (c *BoundContract) RawCreationTransact(opts *TransactOpts, calldata []byte)
272272
// Transfer initiates a plain transaction to move funds to the contract, calling
273273
// its default method if one is available.
274274
func (c *BoundContract) Transfer(opts *TransactOpts) (*types.Transaction, error) {
275-
// todo(rjl493456442) check the payable fallback or receive is defined
276-
// or not, reject invalid transaction at the first place
275+
// Check if payable fallback or receive is defined
276+
if !c.abi.HasReceive() && (!c.abi.HasFallback() || !c.abi.Fallback.Payable) {
277+
return nil, fmt.Errorf("contract does not have a payable fallback or receive function")
278+
}
279+
277280
return c.transact(opts, &c.address, nil)
278281
}
279282

0 commit comments

Comments
 (0)