internal

package
v1.10.0-beta.20201225 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2020 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RecommendedSeedLen is the recommended length in bytes for a seed
	// to a master node.
	RecommendedSeedLen = 32 // 256 bits

	// MinSeedBytes is the minimum number of bytes allowed for a seed to
	// a master node.
	MinSeedBytes = 16 // 128 bits

	// MaxSeedBytes is the maximum number of bytes allowed for a seed to
	// a master node.
	MaxSeedBytes = 64 // 512 bits

)
View Source
const (
	SymbolBBC = "BBC"
	SymbolMKF = "MKF"
)

Variables

View Source
var (

	// ErrDeriveBeyondMaxDepth describes an error in which the caller
	// has attempted to derive more than 255 keys from a root key.
	ErrDeriveBeyondMaxDepth = errors.New("cannot derive a key with more than " +
		"255 indices in its path")

	// ErrInvalidSeedLen describes an error in which the provided seed or
	// seed length is not in the allowed range.
	ErrInvalidSeedLen = fmt.Errorf("seed length must be between %d and %d "+
		"bits", MinSeedBytes*8, MaxSeedBytes*8)
)

Functions

func DecodeSymbolTx

func DecodeSymbolTx(symbol, txData string) (string, error)

func NewWallet

func NewWallet(symbol string, seed []byte, path string, bip44Key string, additionalDeriveParam *bip44.AdditionalDeriveParam) (core.Coin, error)

NewWallet new bbc coin implementation, 只推导1个地址 bip44Key 不为空时用来查找bip44 id,否则使用symbol查找

func SymbolSerializer

func SymbolSerializer(symbol string) gobbc.Serializer

func TryParseTxDataWithTemplate

func TryParseTxDataWithTemplate(msg string) *gobbc.TXData

Types

type ExtendedKey

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

ExtendedKey houses all the information needed to support a hierarchical deterministic extended key. See the package overview documentation for more details on how to use extended keys.

func NewExtendedKey

func NewExtendedKey(version, key, chainCode, parentFP []byte, depth uint8,
	childNum uint32) *ExtendedKey

NewExtendedKey returns a new instance of an extended key with the given fields. No error checking is performed here as it's only intended to be a convenience method used to create a populated struct. This function should only by used by applications that need to create custom ExtendedKeys. All other applications should just use NewMaster, Child, or Neuter.

func NewMaster

func NewMaster(seed []byte) (*ExtendedKey, error)

NewMaster creates a new master node for use in creating a hierarchical deterministic key chain. The seed must be between 128 and 512 bits and should be generated by a cryptographically secure random generation source.

NOTE: There is an extremely small chance (< 1 in 2^127) the provided seed will derive to an unusable secret key. The ErrUnusable error will be returned if this should occur, so the caller must check for it and generate a new seed accordingly.

func (*ExtendedKey) Child

func (k *ExtendedKey) Child(i uint32) (*ExtendedKey, error)

Child returns a derived child extended key at the given index. When this extended key is a private extended key (as determined by the IsPrivate function), a private extended key will be derived. Otherwise, the derived extended key will be also be a public extended key.

When the index is greater to or equal than the HardenedKeyStart constant, the derived extended key will be a hardened extended key. It is only possible to derive a hardended extended key from a private extended key. Consequently, this function will return ErrDeriveHardFromPublic if a hardened child extended key is requested from a public extended key.

A hardened extended key is useful since, as previously mentioned, it requires a parent private extended key to derive. In other words, normal child extended public keys can be derived from a parent public extended key (no knowledge of the parent private key) whereas hardened extended keys may not be.

NOTE: There is an extremely small chance (< 1 in 2^127) the specific child index does not derive to a usable child. The ErrInvalidChild error will be returned if this should occur, and the caller is expected to ignore the invalid child and simply increment to the next index.

type SymbolService

type SymbolService struct {
	Symbol string
}

SymbolService 仅和symbol有关的逻辑

func (*SymbolService) DecodeTx

func (s *SymbolService) DecodeTx(msg string) (string, error)

DecodeTx decodes raw tx to human readable format

func (*SymbolService) SignTemplate

func (s *SymbolService) SignTemplate(msg, templateData, privateKey string) (sig string, err error)

SignTemplate signs raw tx with privateKey

type Wallet

type Wallet struct {
	SymbolService
	DerivationPath accounts.DerivationPath
	MasterKey      *ExtendedKey
}

Wallet BBC core.Coin implementation

func (*Wallet) DeriveAddress

func (c *Wallet) DeriveAddress() (address string, err error)

DeriveAddress derives the account address of the derivation path.

func (*Wallet) DerivePrivateKey

func (c *Wallet) DerivePrivateKey() (privateKey string, err error)

DerivePrivateKey derives the private key of the derivation path.

func (*Wallet) DerivePublicKey

func (c *Wallet) DerivePublicKey() (publicKey string, err error)

DerivePublicKey derives the public key of the derivation path.

func (*Wallet) RawKey

func (c *Wallet) RawKey() ([]byte, error)

RawKey 32+32

func (*Wallet) Sign

func (c *Wallet) Sign(msg, privateKey string) (string, error)

Sign signs raw tx with privateKey 首先尝试解析为带模版数据的待签数据,无法解析则尝试一般原始交易

func (*Wallet) VerifySignature

func (c *Wallet) VerifySignature(pubKey, msg, signature string) error

VerifySignature verifies rawTx's signature is intact

Jump to

Keyboard shortcuts

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