func (self *XEth) sign(tx *types.Transaction, from common.Address, didUnlock bool) error { hash := tx.Hash() sig, err := self.doSign(from, hash, didUnlock) if err != nil { return err } tx.SetSignatureValues(sig) return nil }
func (self *XEth) sign(tx *types.Transaction, from common.Address, didUnlock bool) error { sig, err := self.backend.AccountManager().Sign(accounts.Account{Address: from.Bytes()}, tx.Hash().Bytes()) if err == accounts.ErrLocked { if didUnlock { return fmt.Errorf("sender account still locked after successful unlock") } if !self.frontend.UnlockAccount(from.Bytes()) { return fmt.Errorf("could not unlock sender account") } // retry signing, the account should now be unlocked. return self.sign(tx, from, true) } else if err != nil { return err } tx.SetSignatureValues(sig) return nil }