mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
tx from
This commit is contained in:
parent
b1c5475f4f
commit
c00d2dc9aa
2 changed files with 65 additions and 53 deletions
|
|
@ -86,8 +86,7 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m
|
||||||
// Add tx signed to local tx pool.
|
// Add tx signed to local tx pool.
|
||||||
err = pool.AddLocal(txSigned)
|
err = pool.AddLocal(txSigned)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to add tx sign to local pool.", "error", err, "number", block.NumberU64(), "hash", block.Hash().Hex(), "from", account.Address, "nonce", nonce)
|
log.Warn("Fail to add tx sign to local pool.", "error", err, "number", block.NumberU64(), "hash", block.Hash().Hex(), "from", account.Address, "nonce", nonce)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create secret tx.
|
// Create secret tx.
|
||||||
|
|
@ -116,7 +115,6 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m
|
||||||
err = pool.AddLocal(txSigned)
|
err = pool.AddLocal(txSigned)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to add tx secret to local pool.", "error", err, "number", block.NumberU64(), "hash", block.Hash().Hex(), "from", account.Address, "nonce", nonce)
|
log.Error("Fail to add tx secret to local pool.", "error", err, "number", block.NumberU64(), "hash", block.Hash().Hex(), "from", account.Address, "nonce", nonce)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put randomize key into chainDb.
|
// Put randomize key into chainDb.
|
||||||
|
|
@ -128,7 +126,6 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m
|
||||||
randomizeKeyValue, err := chainDb.Get(randomizeKeyName)
|
randomizeKeyValue, err := chainDb.Get(randomizeKeyName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to get randomize key from state db.", "error", err)
|
log.Error("Fail to get randomize key from state db.", "error", err)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tx, err := BuildTxOpeningRandomize(nonce+1, common.HexToAddress(common.RandomizeSMC), randomizeKeyValue)
|
tx, err := BuildTxOpeningRandomize(nonce+1, common.HexToAddress(common.RandomizeSMC), randomizeKeyValue)
|
||||||
|
|
@ -145,7 +142,6 @@ func CreateTransactionSign(chainConfig *params.ChainConfig, pool *core.TxPool, m
|
||||||
err = pool.AddLocal(txSigned)
|
err = pool.AddLocal(txSigned)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to add tx opening to local pool.", "error", err, "number", block.NumberU64(), "hash", block.Hash().Hex(), "from", account.Address, "nonce", nonce)
|
log.Error("Fail to add tx opening to local pool.", "error", err, "number", block.NumberU64(), "hash", block.Hash().Hex(), "from", account.Address, "nonce", nonce)
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear randomize key in state db.
|
// Clear randomize key in state db.
|
||||||
|
|
@ -221,18 +217,15 @@ func GetRandomizeFromContract(client bind.ContractBackend, addrMasternode common
|
||||||
randomize, err := randomizeContract.NewTomoRandomize(common.HexToAddress(common.RandomizeSMC), client)
|
randomize, err := randomizeContract.NewTomoRandomize(common.HexToAddress(common.RandomizeSMC), client)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail to get instance of randomize", "error", err)
|
log.Error("Fail to get instance of randomize", "error", err)
|
||||||
return -1, err
|
|
||||||
}
|
}
|
||||||
opts := new(bind.CallOpts)
|
opts := new(bind.CallOpts)
|
||||||
secrets, err := randomize.GetSecret(opts, addrMasternode)
|
secrets, err := randomize.GetSecret(opts, addrMasternode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail get secrets from randomize", "error", err)
|
log.Error("Fail get secrets from randomize", "error", err)
|
||||||
return -1, err
|
|
||||||
}
|
}
|
||||||
opening, err := randomize.GetOpening(opts, addrMasternode)
|
opening, err := randomize.GetOpening(opts, addrMasternode)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Fail get opening from randomize", "error", err)
|
log.Error("Fail get opening from randomize", "error", err)
|
||||||
return -1, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DecryptRandomizeFromSecretsAndOpening(secrets, opening)
|
return DecryptRandomizeFromSecretsAndOpening(secrets, opening)
|
||||||
|
|
@ -297,7 +290,6 @@ func DecryptRandomizeFromSecretsAndOpening(secrets [][32]byte, opening [32]byte)
|
||||||
intNumber, err := strconv.Atoi(decryptSecret)
|
intNumber, err := strconv.Atoi(decryptSecret)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Can not convert string to integer", "error", err)
|
log.Error("Can not convert string to integer", "error", err)
|
||||||
return -1, err
|
|
||||||
}
|
}
|
||||||
random = int64(intNumber)
|
random = int64(intNumber)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,19 @@ func (tx *Transaction) To() *common.Address {
|
||||||
return &to
|
return &to
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tx *Transaction) From() *common.Address {
|
||||||
|
if tx.data.V != nil {
|
||||||
|
signer := deriveSigner(tx.data.V)
|
||||||
|
if f, err := Sender(signer, tx); err != nil {
|
||||||
|
return nil
|
||||||
|
} else {
|
||||||
|
return &f
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Hash hashes the RLP encoding of tx.
|
// Hash hashes the RLP encoding of tx.
|
||||||
// It uniquely identifies the transaction.
|
// It uniquely identifies the transaction.
|
||||||
func (tx *Transaction) Hash() common.Hash {
|
func (tx *Transaction) Hash() common.Hash {
|
||||||
|
|
@ -274,6 +287,13 @@ func (tx *Transaction) IsSpecialTransaction() bool {
|
||||||
return tx.To().String() == common.RandomizeSMC || tx.To().String() == common.BlockSigners
|
return tx.To().String() == common.RandomizeSMC || tx.To().String() == common.BlockSigners
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tx *Transaction) IsSigningTransaction() bool {
|
||||||
|
if tx.To() == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return tx.To().String() == common.BlockSigners
|
||||||
|
}
|
||||||
|
|
||||||
func (tx *Transaction) String() string {
|
func (tx *Transaction) String() string {
|
||||||
var from, to string
|
var from, to string
|
||||||
if tx.data.V != nil {
|
if tx.data.V != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue