Merge pull request #70 from tendermint/bondtx
add bonder's signature to BondTx
This commit is contained in:
commit
e5537b065c
|
@ -99,9 +99,12 @@ func SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (*ctypes.ResponseS
|
|||
callTx.Input.Signature = privAccounts[0].Sign(callTx)
|
||||
case *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 {
|
||||
input.PubKey = privAccounts[i].PubKey
|
||||
input.Signature = privAccounts[i].Sign(bondTx)
|
||||
input.PubKey = privAccounts[i+1].PubKey
|
||||
input.Signature = privAccounts[i+1].Sign(bondTx)
|
||||
}
|
||||
case *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 {
|
||||
return err
|
||||
}
|
||||
if !tx.PubKey.VerifyBytes(signBytes, tx.Signature) {
|
||||
return types.ErrTxInvalidSignature
|
||||
}
|
||||
outTotal, err := validateOutputs(tx.UnbondTo)
|
||||
if err != nil {
|
||||
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)
|
||||
err := execTxWithState(state, tx, true)
|
||||
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)
|
||||
|
||||
// Make complete block and blockParts
|
||||
|
|
|
@ -179,9 +179,10 @@ func (tx *CallTx) String() string {
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
type BondTx struct {
|
||||
PubKey account.PubKeyEd25519 `json:"pub_key"`
|
||||
Inputs []*TxInput `json:"inputs"`
|
||||
UnbondTo []*TxOutput `json:"unbond_to"`
|
||||
PubKey account.PubKeyEd25519 `json:"pub_key"`
|
||||
Signature account.SignatureEd25519 `json:"signature"`
|
||||
Inputs []*TxInput `json:"inputs"`
|
||||
UnbondTo []*TxOutput `json:"unbond_to"`
|
||||
}
|
||||
|
||||
func (tx *BondTx) WriteSignBytes(w io.Writer, n *int64, err *error) {
|
||||
|
|
Loading…
Reference in New Issue