mirror of
https://github.com/fluencelabs/tendermint
synced 2025-06-29 04:31:44 +00:00
add bonder's signature to BondTx
This commit is contained in:
@ -99,9 +99,12 @@ func SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*ctypes.ResponseS
|
|||||||
callTx.Input.Signature = privAccounts[0].Sign(callTx)
|
callTx.Input.Signature = privAccounts[0].Sign(callTx)
|
||||||
case *types.BondTx:
|
case *types.BondTx:
|
||||||
bondTx := tx.(*types.BondTx)
|
bondTx := tx.(*types.BondTx)
|
||||||
|
// the first privaccount corresponds to the BondTx pub key.
|
||||||
|
// the rest to the inputs
|
||||||
|
bondTx.Signature = privAccounts[0].Sign(bondTx).(account.SignatureEd25519)
|
||||||
for i, input := range bondTx.Inputs {
|
for i, input := range bondTx.Inputs {
|
||||||
input.PubKey = privAccounts[i].PubKey
|
input.PubKey = privAccounts[i+1].PubKey
|
||||||
input.Signature = privAccounts[i].Sign(bondTx)
|
input.Signature = privAccounts[i+1].Sign(bondTx)
|
||||||
}
|
}
|
||||||
case *types.UnbondTx:
|
case *types.UnbondTx:
|
||||||
unbondTx := tx.(*types.UnbondTx)
|
unbondTx := tx.(*types.UnbondTx)
|
||||||
|
@ -497,6 +497,9 @@ func ExecTx(blockCache *BlockCache, tx_ types.Tx, runCall bool, evc events.Firea
|
|||||||
if err := tx.PubKey.ValidateBasic(); err != nil {
|
if err := tx.PubKey.ValidateBasic(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if !tx.PubKey.VerifyBytes(signBytes, tx.Signature) {
|
||||||
|
return types.ErrTxInvalidSignature
|
||||||
|
}
|
||||||
outTotal, err := validateOutputs(tx.UnbondTo)
|
outTotal, err := validateOutputs(tx.UnbondTo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -288,6 +288,7 @@ func TestTxs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
tx.Signature = privAccounts[0].Sign(tx).(account.SignatureEd25519)
|
||||||
tx.Inputs[0].Signature = privAccounts[0].Sign(tx)
|
tx.Inputs[0].Signature = privAccounts[0].Sign(tx)
|
||||||
err := execTxWithState(state, tx, true)
|
err := execTxWithState(state, tx, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -344,6 +345,7 @@ func TestAddValidator(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
bondTx.Signature = acc0.Sign(bondTx).(account.SignatureEd25519)
|
||||||
bondTx.Inputs[0].Signature = acc0.Sign(bondTx)
|
bondTx.Inputs[0].Signature = acc0.Sign(bondTx)
|
||||||
|
|
||||||
// Make complete block and blockParts
|
// Make complete block and blockParts
|
||||||
|
@ -179,9 +179,10 @@ func (tx *CallTx) String() string {
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
type BondTx struct {
|
type BondTx struct {
|
||||||
PubKey account.PubKeyEd25519 `json:"pub_key"`
|
PubKey account.PubKeyEd25519 `json:"pub_key"`
|
||||||
Inputs []*TxInput `json:"inputs"`
|
Signature account.SignatureEd25519 `json:"signature"`
|
||||||
UnbondTo []*TxOutput `json:"unbond_to"`
|
Inputs []*TxInput `json:"inputs"`
|
||||||
|
UnbondTo []*TxOutput `json:"unbond_to"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||||
|
Reference in New Issue
Block a user