multisig

package
v0.3.2-beta.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

nolint

nolint

Index

Constants

View Source
const (
	// BaseGas is a cost of Parse and Verify methods.
	BaseGas1 = 100
	BaseGas2 = 200
	BaseGas3 = 300

	// FixedGasSpawn1 is consumed from principal in case of successful spawn.
	FixedGasSpawn1 = 100
	// FixedGasSpend1 is consumed from principal in case of successful spend.
	FixedGasSpend1 = 100

	// FixedGasSpawn2 is consumed from principal in case of successful spawn.
	FixedGasSpawn2 = 200
	// FixedGasSpend2 is consumed from principal in case of successful spend.
	FixedGasSpend2 = 200

	// FixedGasSpawn3 is consumed from principal in case of successful spawn.
	FixedGasSpawn3 = 300
	// FixedGasSpend3 is consumed from principal in case of successful spend.
	FixedGasSpend3 = 300

	// StorageLimit is a limit of keys that can be used when multisig is spawned.
	StorageLimit = 10
)

Variables

View Source
var (

	// TemplateAddress1 is an address of the 1/N multisig template.
	TemplateAddress1 core.Address
	// TemplateAddress2 is an address of the 2/N multisig template.
	TemplateAddress2 core.Address
	// TemplateAddress3 is an address of the 3/N multisig template.
	TemplateAddress3 core.Address
)

Functions

func NewHandler

func NewHandler(address core.Address, k uint8, baseGas, gasSpawn, gasSpend uint64) core.Handler

NewHandler instantiates multisig handler with a particular configuration.

func Register

func Register(registry *registry.Registry)

Register template.

Types

type MultiSig

type MultiSig struct {
	PublicKeys []core.PublicKey `scale:"max=10"`
	// contains filtered or unexported fields
}

MultiSig K/N template.

func (*MultiSig) DecodeScale

func (t *MultiSig) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*MultiSig) EncodeScale

func (t *MultiSig) EncodeScale(enc *scale.Encoder) (total int, err error)

func (*MultiSig) MaxSpend

func (ms *MultiSig) MaxSpend(method uint8, args any) (uint64, error)

MaxSpend returns amount specified in the SpendArguments.

func (*MultiSig) Spend

func (ms *MultiSig) Spend(host core.Host, args *SpendArguments) error

Spend transfers an amount to the address specified in SpendArguments.

func (*MultiSig) Verify

func (ms *MultiSig) Verify(host core.Host, raw []byte, dec *scale.Decoder) bool

Verify that transaction is signed has k valid signatures.

type Part

type Part struct {
	Ref uint8
	Sig core.Signature
}

Part contains a reference to public key and signature from private key counterpart.

func (*Part) DecodeScale

func (t *Part) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*Part) EncodeScale

func (t *Part) EncodeScale(enc *scale.Encoder) (total int, err error)

type Signatures

type Signatures []Part

Signatures is a collections of parts that must satisfy multisig threshold requirement.

type SpawnArguments

type SpawnArguments struct {
	PublicKeys []core.PublicKey `scale:"max=10"` // update StorageLimit if it changes.
}

SpawnArguments contains a collection with PublicKeys.

func (*SpawnArguments) DecodeScale

func (t *SpawnArguments) DecodeScale(dec *scale.Decoder) (total int, err error)

func (*SpawnArguments) EncodeScale

func (t *SpawnArguments) EncodeScale(enc *scale.Encoder) (total int, err error)

type SpendArguments

type SpendArguments = wallet.SpendArguments

SpendArguments ...

type SpendTemplate

type SpendTemplate interface {
	Spend(core.Host, *SpendArguments) error
}

SpendTemplate interface for the template that support Spend method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL