xpriv

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Key

type Key interface {
	XPriv() string
	XPub() PubKey
}

Key represents basic key methods

func FromString

func FromString(xpriv string) (Key, error)

FromString generates keys from given xpriv

type KeyWithMnemonic

type KeyWithMnemonic interface {
	Key
	Mnemonic() string
}

KeyWithMnemonic represents methods for generated keys

func FromMnemonic

func FromMnemonic(mnemonic string) (KeyWithMnemonic, error)

FromMnemonic generates Keys based on given mnemonic

Example
package main

import (
	"fmt"

	"github.com/bitcoin-sv/spv-wallet-go-client/xpriv"
)

func main() {
	keys, _ := xpriv.FromMnemonic("absorb corn ostrich order sing boost just harvest enable make detail future desert bus adult")

	fmt.Println("mnemonic:", keys.Mnemonic())
	fmt.Println("xpriv:", keys.XPriv())
	fmt.Println("xpub:", keys.XPub().String())

}
Output:

mnemonic: absorb corn ostrich order sing boost just harvest enable make detail future desert bus adult
xpriv: xprv9s21ZrQH143K3Lh4wdicqvYNMcdh49rMLqDvQoyys8L6f5tfE2WkQN7ZVE2awBrfVWNSJ8pPd4QLLr94Nur85Dvj8kD8RoZghBuNTpvL8si
xpub: xpub661MyMwAqRbcFpmY3fFdD4V6ueUBTcaCi49XDCPbRTs5XtDomZpzxAS3LUb2hMfUVphDsSPxfjietmsBRFkLDY9Xa3P4jbgNDMnDK3UqJe2

func Generate

func Generate() (KeyWithMnemonic, error)

Generate generates a random set of keys - xpriv, xpb and mnemonic

Example
package main

import (
	"fmt"

	"github.com/bitcoin-sv/spv-wallet-go-client/xpriv"
)

func main() {
	keys, _ := xpriv.Generate()

	fmt.Println("xpriv:", keys.XPriv())
	fmt.Println("xpub:", keys.XPub().String())
}
Output:

type Keys

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

Keys is a struct containing the xpriv, xpub and mnemonic

func (*Keys) Mnemonic

func (k *Keys) Mnemonic() string

Mnemonic return mnemonic from which keys where generated

func (*Keys) XPriv

func (k *Keys) XPriv() string

XPriv return hierarchical deterministic private key

func (*Keys) XPub

func (k *Keys) XPub() PubKey

XPub return hierarchical struct which contain xpub info

type PubKey

type PubKey interface {
	String() string
}

PubKey represents public key methods

type PublicKey

type PublicKey string

PublicKey is a struct containing public key information

func (PublicKey) String

func (k PublicKey) String() string

String return hierarchical deterministic publick ey

Jump to

Keyboard shortcuts

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