MCPcopy Create free account
hub / github.com/chain/Core / BlockMultiSigProgram

Function BlockMultiSigProgram

protocol/vmutil/script.go:23–35  ·  view source on GitHub ↗

BlockMultiSigProgram returns a valid multisignature consensus program where nrequired of the keys in pubkeys are required to have signed the block for success. An ErrBadValue will be returned if nrequired is larger than the number of keys provided. The result is: BLOCKHASH ...

(pubkeys []ed25519.PublicKey, nrequired int)

Source from the content-addressed store, hash-verified

21// nrequired is larger than the number of keys provided. The result
22// is: BLOCKHASH <pubkey>... <nrequired> <npubkeys> CHECKMULTISIG
23func BlockMultiSigProgram(pubkeys []ed25519.PublicKey, nrequired int) ([]byte, error) {
24 err := checkMultiSigParams(int64(nrequired), int64(len(pubkeys)))
25 if err != nil {
26 return nil, err
27 }
28 builder := NewBuilder()
29 builder.AddOp(vm.OP_BLOCKHASH)
30 for _, key := range pubkeys {
31 builder.AddData(key)
32 }
33 builder.AddInt64(int64(nrequired)).AddInt64(int64(len(pubkeys))).AddOp(vm.OP_CHECKMULTISIG)
34 return builder.Program, nil
35}
36
37func ParseBlockMultiSigProgram(script []byte) ([]ed25519.PublicKey, int, error) {
38 pops, err := vm.ParseProgram(script)

Callers 4

Test00MultisigFunction · 0.85
Test01MultisigFunction · 0.85
TestParse00MultisigFunction · 0.85
TestBlockMultisigFunction · 0.85

Calls 5

AddOpMethod · 0.95
AddDataMethod · 0.95
AddInt64Method · 0.95
checkMultiSigParamsFunction · 0.85
NewBuilderFunction · 0.70

Tested by 4

Test00MultisigFunction · 0.68
Test01MultisigFunction · 0.68
TestParse00MultisigFunction · 0.68
TestBlockMultisigFunction · 0.68