signing

package
v4.13.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2019 License: Apache-2.0 Imports: 12 Imported by: 45

Documentation

Index

Constants

View Source
const (

	// Hardened denotes a hardened key derivation.
	Hardened = true

	// NonHardened denotes a non-hardened key derivation.
	NonHardened = false
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AbsoluteKeypath

type AbsoluteKeypath keypath

AbsoluteKeypath models an absolute keypath according to BIP32.

func NewAbsoluteKeypath

func NewAbsoluteKeypath(input string) (AbsoluteKeypath, error)

NewAbsoluteKeypath creates a new absolute keypath from a string like `m/44'/1'`.

func NewEmptyAbsoluteKeypath

func NewEmptyAbsoluteKeypath() AbsoluteKeypath

NewEmptyAbsoluteKeypath creates a new empty absolute keypath.

func (AbsoluteKeypath) Append

func (absoluteKeypath AbsoluteKeypath) Append(suffix RelativeKeypath) AbsoluteKeypath

Append appends a relative keypath to this absolute keypath.

func (AbsoluteKeypath) Child

func (absoluteKeypath AbsoluteKeypath) Child(index uint32, hardened bool) AbsoluteKeypath

Child appends the given node to this absolute keypath.

func (AbsoluteKeypath) Derive

func (absoluteKeypath AbsoluteKeypath) Derive(
	extendedKey *hdkeychain.ExtendedKey,
) (*hdkeychain.ExtendedKey, error)

Derive derives the extended key at this path from the given extended key.

func (AbsoluteKeypath) Encode

func (absoluteKeypath AbsoluteKeypath) Encode() string

Encode encodes the absolute keypath as a string.

func (AbsoluteKeypath) MarshalJSON

func (absoluteKeypath AbsoluteKeypath) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (AbsoluteKeypath) ToUInt32

func (absoluteKeypath AbsoluteKeypath) ToUInt32() []uint32

ToUInt32 returns the keypath as child numbers. Hardened children have an offset of 0x80000000.

func (*AbsoluteKeypath) UnmarshalJSON

func (absoluteKeypath *AbsoluteKeypath) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements json.Unmarshaler.

type Configuration

type Configuration struct {
	// contains filtered or unexported fields
}

Configuration models a signing configuration, which can be singlesig, multisig or address based.

func NewAddressConfiguration

func NewAddressConfiguration(
	scriptType ScriptType,
	absoluteKeypath AbsoluteKeypath,
	address string,
) *Configuration

NewAddressConfiguration creates a new account address configuration

func NewConfiguration

func NewConfiguration(
	scriptType ScriptType,
	absoluteKeypath AbsoluteKeypath,
	extendedPublicKeys []*hdkeychain.ExtendedKey,
	address string,
	signingThreshold int,
) *Configuration

NewConfiguration creates a new configuration. At the moment, multisig is a predefined multisig-P2SH script, and is active if there are more than one xpubs. Otherwise, it's single sig and `scriptType` defines the type of script.

func NewSinglesigConfiguration

func NewSinglesigConfiguration(
	scriptType ScriptType,
	absoluteKeypath AbsoluteKeypath,
	extendedPublicKey *hdkeychain.ExtendedKey,
) *Configuration

NewSinglesigConfiguration creates a new singlesig configuration.

func (*Configuration) AbsoluteKeypath

func (configuration *Configuration) AbsoluteKeypath() AbsoluteKeypath

AbsoluteKeypath returns the configuration's keypath.

func (*Configuration) Address

func (configuration *Configuration) Address() string

Address returns the configuration's address

func (*Configuration) Derive

func (configuration *Configuration) Derive(relativeKeypath RelativeKeypath) (*Configuration, error)

Derive derives a subkeypath from the configuration's base absolute keypath.

func (*Configuration) ExtendedPublicKeys

func (configuration *Configuration) ExtendedPublicKeys() []*hdkeychain.ExtendedKey

ExtendedPublicKeys returns the configuration's extended public keys.

func (*Configuration) Hash

func (configuration *Configuration) Hash() string

Hash returns a hash of the configuration.

func (*Configuration) IsAddressBased

func (configuration *Configuration) IsAddressBased() bool

IsAddressBased returns whether configuration is address based or not

func (Configuration) MarshalJSON

func (configuration Configuration) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Configuration) Multisig

func (configuration *Configuration) Multisig() bool

Multisig returns whether this is a multisig configuration.

func (*Configuration) NumberOfSigners

func (configuration *Configuration) NumberOfSigners() int

NumberOfSigners returns the number of signers (1 in single sig, N in a M/N multisig).

func (*Configuration) PublicKeys

func (configuration *Configuration) PublicKeys() []*btcec.PublicKey

PublicKeys returns the configuration's public keys.

func (*Configuration) ScriptType

func (configuration *Configuration) ScriptType() ScriptType

ScriptType returns the configuration's keypath.

func (*Configuration) SigningThreshold

func (configuration *Configuration) SigningThreshold() int

SigningThreshold returns the signing threshold in case of a multisig config.

func (*Configuration) Singlesig

func (configuration *Configuration) Singlesig() bool

Singlesig returns whether this is a singlesig configuration.

func (*Configuration) SortedPublicKeys

func (configuration *Configuration) SortedPublicKeys() []*btcec.PublicKey

SortedPublicKeys returns the configuration's public keys sorted in compressed form.

func (*Configuration) String

func (configuration *Configuration) String() string

String returns a short summary of the configuration to be used in logs, etc.

func (*Configuration) UnmarshalJSON

func (configuration *Configuration) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements json.Unmarshaler.

type RelativeKeypath

type RelativeKeypath keypath

RelativeKeypath models a relative keypath according to BIP32.

func NewEmptyRelativeKeypath

func NewEmptyRelativeKeypath() RelativeKeypath

NewEmptyRelativeKeypath creates a new empty relative keypath.

func NewRelativeKeypath

func NewRelativeKeypath(input string) (RelativeKeypath, error)

NewRelativeKeypath creates a new relative keypath from a string like `1/2'/3`.

func (RelativeKeypath) Child

func (relativeKeypath RelativeKeypath) Child(index uint32, hardened bool) RelativeKeypath

Child appends the given node to this relative keypath.

func (RelativeKeypath) Derive

func (relativeKeypath RelativeKeypath) Derive(
	extendedKey *hdkeychain.ExtendedKey,
) (*hdkeychain.ExtendedKey, error)

Derive derives the extended key at this path from the given extended key.

func (RelativeKeypath) Encode

func (relativeKeypath RelativeKeypath) Encode() string

Encode encodes the relative keypath as a string.

func (RelativeKeypath) Hardened

func (relativeKeypath RelativeKeypath) Hardened() bool

Hardened returns whether the keypath contains a hardened derivation.

func (RelativeKeypath) ToUInt32

func (relativeKeypath RelativeKeypath) ToUInt32() []uint32

ToUInt32 returns the keypath as child numbers. Hardened children have an offset of 0x80000000.

type ScriptType

type ScriptType string

ScriptType indicates which type of output should be produced in case of singlesig.

const (
	// ScriptTypeP2PKH is a PayToPubKeyHash output.
	ScriptTypeP2PKH ScriptType = "p2pkh"

	// ScriptTypeP2WPKHP2SH is a segwit PayToPubKeyHash output wrapped in p2sh.
	ScriptTypeP2WPKHP2SH ScriptType = "p2wpkh-p2sh"

	// ScriptTypeP2WPKH is a segwit PayToPubKeyHash output.
	ScriptTypeP2WPKH ScriptType = "p2wpkh"
)

func DecodeScriptType

func DecodeScriptType(scriptType string) (ScriptType, error)

DecodeScriptType decodes the given script type or returns an error.

Jump to

Keyboard shortcuts

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