MCPcopy Create free account
hub / github.com/DNAProject/DNA / EncodeMultiPubKeyProgramInto

Function EncodeMultiPubKeyProgramInto

core/program/program.go:103–121  ·  view source on GitHub ↗
(sink *common.ZeroCopySink, pubkeys []keypair.PublicKey, m int)

Source from the content-addressed store, hash-verified

101}
102
103func EncodeMultiPubKeyProgramInto(sink *common.ZeroCopySink, pubkeys []keypair.PublicKey, m int) error {
104 n := len(pubkeys)
105 if !(1 <= m && m <= n && n > 1 && n <= constants.MULTI_SIG_MAX_PUBKEY_SIZE) {
106 return errors.New("wrong multi-sig param")
107 }
108
109 pubkeys = keypair.SortPublicKeys(pubkeys)
110
111 builder := ProgramBuilder{sink: sink}
112 builder.PushNum(uint16(m))
113 for _, pubkey := range pubkeys {
114 key := keypair.SerializePublicKey(pubkey)
115 builder.PushBytes(key)
116 }
117
118 builder.PushNum(uint16(len(pubkeys)))
119 builder.PushOpCode(neovm.CHECKMULTISIG)
120 return nil
121}
122
123func ProgramFromMultiPubKey(pubkeys []keypair.PublicKey, m int) ([]byte, error) {
124 sink := common.ZeroCopySink{}

Callers 2

SerializationMethod · 0.92
ProgramFromMultiPubKeyFunction · 0.85

Calls 3

PushNumMethod · 0.95
PushBytesMethod · 0.95
PushOpCodeMethod · 0.95

Tested by

no test coverage detected