mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
26 lines
805 B
Go
26 lines
805 B
Go
// +build !js
|
|
|
|
package bind
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/ethereum/go-ethereum/accounts"
|
|
"github.com/ethereum/go-ethereum/accounts/external"
|
|
"github.com/ethereum/go-ethereum/common"
|
|
"github.com/ethereum/go-ethereum/core/types"
|
|
)
|
|
|
|
// NewClefTransactor is a utility method to easily create a transaction signer
|
|
// with a clef backend.
|
|
func NewClefTransactor(clef *external.ExternalSigner, account accounts.Account) *TransactOpts {
|
|
return &TransactOpts{
|
|
From: account.Address,
|
|
Signer: func(signer types.Signer, address common.Address, transaction *types.Transaction) (*types.Transaction, error) {
|
|
if address != account.Address {
|
|
return nil, errors.New("not authorized to sign this account")
|
|
}
|
|
return clef.SignTx(account, transaction, nil) // Clef enforces its own chain id
|
|
},
|
|
}
|
|
}
|