-
Notifications
You must be signed in to change notification settings - Fork 113
/
msg_submit_multisig_signatures.go
45 lines (36 loc) · 1.5 KB
/
msg_submit_multisig_signatures.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package types
import (
"github.com/btcsuite/btcd/btcec"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)
// NewSubmitMultisigSignaturesRequest constructor for SubmitMultisigSignaturesRequest
func NewSubmitMultisigSignaturesRequest(sender sdk.AccAddress, sigID string, signatures [][]byte) *SubmitMultisigSignaturesRequest {
return &SubmitMultisigSignaturesRequest{Sender: sender, SigID: sigID, Signatures: signatures}
}
// Route implements the sdk.Msg interface.
func (m SubmitMultisigSignaturesRequest) Route() string { return RouterKey }
// Type implements the sdk.Msg interface.
// naming convention follows x/staking/types/msgs.go
func (m SubmitMultisigSignaturesRequest) Type() string { return "SubmitMultisigSignatures" }
// ValidateBasic implements the sdk.Msg interface.
func (m SubmitMultisigSignaturesRequest) ValidateBasic() error {
if err := sdk.VerifyAddressFormat(m.Sender); err != nil {
return sdkerrors.Wrap(sdkerrors.ErrInvalidAddress, sdkerrors.Wrap(err, "sender").Error())
}
for _, sig := range m.Signatures {
_, err := btcec.ParseDERSignature(sig, btcec.S256())
if err != nil {
return err
}
}
return nil
}
// GetSignBytes implements the sdk.Msg interface
func (m SubmitMultisigSignaturesRequest) GetSignBytes() []byte {
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m))
}
// GetSigners implements the sdk.Msg interface
func (m SubmitMultisigSignaturesRequest) GetSigners() []sdk.AccAddress {
return []sdk.AccAddress{m.Sender}
}