Documentation ¶
Index ¶
- Constants
- Variables
- func DecodeSymbolTx(symbol, txData string) (string, error)
- func NewSimpleWallet(symbol string, seed []byte) (core.Coin, error)
- func NewWallet(symbol string, seed []byte, path string, bip44Key string, ...) (core.Coin, error)
- func SymbolSerializer(symbol string) gobbc.Serializer
- type ExtendedKey
- type SymbolService
- type Wallet
- func (c *Wallet) DeriveAddress() (address string, err error)
- func (c *Wallet) DerivePrivateKey() (privateKey string, err error)
- func (c *Wallet) DerivePublicKey() (publicKey string, err error)
- func (c *Wallet) Sign(msg, privateKey string) (string, error)
- func (c *Wallet) VerifySignature(pubKey, msg, signature string) error
Constants ¶
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 )
const ( SymbolBBC = "BBC" SymbolMKF = "MKF" )
Variables ¶
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 NewSimpleWallet ¶
NewSimpleWallet new bbc coin implementation, with short bip44 path
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
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 ¶
DeriveAddress derives the account address of the derivation path.
func (*Wallet) DerivePrivateKey ¶
DerivePrivateKey derives the private key of the derivation path.
func (*Wallet) DerivePublicKey ¶
DerivePublicKey derives the public key of the derivation path.
func (*Wallet) VerifySignature ¶
VerifySignature verifies rawTx's signature is intact