Documentation ¶
Overview ¶
Example (NewWallet) ¶
seedHex := "fded5e8970380eef15f742348d28511111366ae6a55188402b16c69922006fe6" seed, err := hex.DecodeString(seedHex) if err != nil { log.Fatal(err) } walletData := "wallet.dat" w := wallet.New(seed, walletData) coinAccount, err := w.CoinAccount(wallet.BTC, wallet.Test(true), 0) if err != nil { log.Fatal(err) } address, err := coinAccount.NewExternalAddr() if err != nil { log.Fatal(err) } fmt.Println(address)
Output: mjWfeKTxhPD2eA9FbVrqTkGtZD19fHEgaU
Index ¶
- Constants
- Variables
- type AccountStore
- type BoltAccountStore
- func (b BoltAccountStore) Close()
- func (b BoltAccountStore) GetAllUTXO() (map[string]tx.UTXOs, error)
- func (b BoltAccountStore) GetLastIndex() (uint64, error)
- func (b BoltAccountStore) GetUTXO(address string) (tx.UTXOs, error)
- func (b BoltAccountStore) SetLastIndex(index uint64) error
- func (b BoltAccountStore) SetUTXO(address string, utxos tx.UTXOs) error
- type CoinAccount
- func (c CoinAccount) Address(i uint32, change bool) (string, error)
- func (c *CoinAccount) Close()
- func (c CoinAccount) Discover() error
- func (c CoinAccount) GetBalance() (uint64, error)
- func (c CoinAccount) NewChangeAddr() (string, error)
- func (c CoinAccount) NewExternalAddr() (string, error)
- func (c CoinAccount) Send(sends []*tx.Send, customData []byte, fee uint64) (string, string, error)
- func (c *CoinAccount) SetAgent(a agent.CoinAgent)
- func (c CoinAccount) String() string
- type CoinType
- type Test
- type UnspentFunds
- type Wallet
Examples ¶
Constants ¶
View Source
const (
AddressGap = 5
)
Follow the rule of account discovery in BIP44 https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki#account-discovery
Variables ¶
View Source
var ( //BitcoinMain is params for main net. BitcoinMain = &address.Params{ DumpedPrivateKeyHeader: []byte{128}, AddressHeader: 0, P2SHHeader: 5, HDPrivateKeyID: []byte{0x04, 0x88, 0xad, 0xe4}, HDPublicKeyID: []byte{0x04, 0x88, 0xb2, 0x1e}, } //BitcoinTest is params for test net. BitcoinTest = &address.Params{ DumpedPrivateKeyHeader: []byte{239}, AddressHeader: 111, P2SHHeader: 196, HDPrivateKeyID: []byte{0x04, 0x35, 0x83, 0x94}, HDPublicKeyID: []byte{0x04, 0x35, 0x87, 0xcf}, } //LitecoinMain is params for litecoin main net. LitecoinMain = &address.Params{ DumpedPrivateKeyHeader: []byte{176}, AddressHeader: 48, P2SHHeader: 50, HDPrivateKeyID: []byte{0x04, 0x88, 0xad, 0xe4}, HDPublicKeyID: []byte{0x04, 0x88, 0xb2, 0x1e}, } //LitecoinTest is params for litecoin test net. LitecoinTest = &address.Params{ DumpedPrivateKeyHeader: []byte{239}, AddressHeader: 111, P2SHHeader: 58, HDPrivateKeyID: []byte{0x04, 0x35, 0x83, 0x94}, HDPublicKeyID: []byte{0x04, 0x35, 0x87, 0xcf}, } )
View Source
var ( ErrAccountBucketNotExisted = fmt.Errorf("account bucket is not existed") ErrUTXOBucketNotExisted = fmt.Errorf("utxo bucket is not existed") )
View Source
var ( ErrNotEnoughCoin = fmt.Errorf("not enough of coins in the wallet") ErrNilAccountStore = fmt.Errorf("no account store is set") )
View Source
var CoinFee = map[CoinType]uint64{ BTC: 1000, LTC: 10000, }
View Source
var CoinMap = map[CoinType]uint32{ BTC: 0, LTC: 2, }
Functions ¶
This section is empty.
Types ¶
type AccountStore ¶
type BoltAccountStore ¶
type BoltAccountStore struct {
// contains filtered or unexported fields
}
BoltAccountStore is an account store using boltdb. The wallet data is organized as follow: + bucket (pubkey of coin_account)
- bucket ("utxo")
- address : txs
- lastIndex : varint
func NewBoltAccountStore ¶
func NewBoltAccountStore(filename, account string) (*BoltAccountStore, error)
func (BoltAccountStore) Close ¶
func (b BoltAccountStore) Close()
func (BoltAccountStore) GetAllUTXO ¶
func (b BoltAccountStore) GetAllUTXO() (map[string]tx.UTXOs, error)
func (BoltAccountStore) GetLastIndex ¶
func (b BoltAccountStore) GetLastIndex() (uint64, error)
func (BoltAccountStore) GetUTXO ¶
func (b BoltAccountStore) GetUTXO(address string) (tx.UTXOs, error)
func (BoltAccountStore) SetLastIndex ¶
func (b BoltAccountStore) SetLastIndex(index uint64) error
type CoinAccount ¶
type CoinAccount struct { CoinType CoinType Test Test Key *address.ExtendedKey // contains filtered or unexported fields }
CoinAccount is the root struct for manipulate coins.
func (CoinAccount) Address ¶
func (c CoinAccount) Address(i uint32, change bool) (string, error)
Address returns a coin address
func (*CoinAccount) Close ¶ added in v0.6.1
func (c *CoinAccount) Close()
func (CoinAccount) Discover ¶
func (c CoinAccount) Discover() error
func (CoinAccount) GetBalance ¶
func (c CoinAccount) GetBalance() (uint64, error)
func (CoinAccount) NewChangeAddr ¶
func (c CoinAccount) NewChangeAddr() (string, error)
func (CoinAccount) NewExternalAddr ¶
func (c CoinAccount) NewExternalAddr() (string, error)
func (*CoinAccount) SetAgent ¶
func (c *CoinAccount) SetAgent(a agent.CoinAgent)
func (CoinAccount) String ¶
func (c CoinAccount) String() string
String returns the identifier of an account.
type UnspentFunds ¶ added in v0.7.0
type Wallet ¶
type Wallet struct {
// contains filtered or unexported fields
}
func (Wallet) CoinAccount ¶
CoinAccount returns an extended account base on BIP44 with the coin type and the account index being specified.
Directories ¶
Path | Synopsis |
---|---|
base85 → bytes and decode the address version substitute for broken decoder in bitgoin/address
|
base85 → bytes and decode the address version substitute for broken decoder in bitgoin/address |
command
|
|
Click to show internal directories.
Click to hide internal directories.