wallet

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: BSD-2-Clause Imports: 21 Imported by: 8

Documentation

Overview

Package wallet models the data for a wallet It is not a complete wallet and only provides basic testing capabilities for rpc currently

Index

Constants

View Source
const (
	ISMINE_NO               uint8 = 0
	ISMINE_WATCH_UNSOLVABLE uint8 = 1
	ISMINE_WATCH_SOLVABLE   uint8 = 2
	ISMINE_WATCH_ONLY       uint8 = ISMINE_WATCH_SOLVABLE | ISMINE_WATCH_UNSOLVABLE
	ISMINE_SPENDABLE        uint8 = 4
	ISMINE_ALL              uint8 = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE
)

Variables

This section is empty.

Functions

func InitWallet

func InitWallet()

func IsUnlockable

func IsUnlockable(scriptPubKey *script.Script) bool

Types

type AddressBook

type AddressBook struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewAddressBook

func NewAddressBook() *AddressBook

func (*AddressBook) GetAccountName

func (ab *AddressBook) GetAccountName(keyHash []byte) string

func (*AddressBook) SetAddressBook

func (ab *AddressBook) SetAddressBook(keyHash []byte, addressBookData *AddressBookData)

type AddressBookData

type AddressBookData struct {
	Account string
	Purpose string
}

func NewAddressBookData

func NewAddressBookData(account string, purpose string) *AddressBookData

func NewEmptyAddressBookData

func NewEmptyAddressBookData() *AddressBookData

func (*AddressBookData) Serialize

func (abd *AddressBookData) Serialize(writer io.Writer) error

func (*AddressBookData) SerializeSize

func (abd *AddressBookData) SerializeSize() int

func (*AddressBookData) Unserialize

func (abd *AddressBookData) Unserialize(reader io.Reader) error

type Recipient

type Recipient struct {
	ScriptPubKey          *script.Script
	Value                 amount.Amount
	SubtractFeeFromAmount bool
}

type ScriptStore

type ScriptStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewScriptStore

func NewScriptStore() *ScriptStore

func (*ScriptStore) AddScript

func (ss *ScriptStore) AddScript(s *script.Script)

func (*ScriptStore) GetScript

func (ss *ScriptStore) GetScript(scriptHash []byte) *script.Script

type Wallet

type Wallet struct {
	*crypto.KeyStore
	*ScriptStore
	*AddressBook
	// contains filtered or unexported fields
}

func GetInstance

func GetInstance() *Wallet

func (*Wallet) AddScript

func (w *Wallet) AddScript(s *script.Script) error

func (*Wallet) AddToWallet

func (w *Wallet) AddToWallet(txn *tx.Tx, blockhash util.Hash, extInfo map[string]string) error

func (*Wallet) GenerateNewKey

func (w *Wallet) GenerateNewKey() (*crypto.PublicKey, error)

func (*Wallet) GetBalance

func (w *Wallet) GetBalance() amount.Amount

func (*Wallet) GetBroadcastTx

func (w *Wallet) GetBroadcastTx() bool

func (*Wallet) GetCreditOut

func (w *Wallet) GetCreditOut(out *txout.TxOut, filter uint8) amount.Amount

func (*Wallet) GetCreditTx

func (w *Wallet) GetCreditTx(walletTx *WalletTx, filter uint8) amount.Amount

func (*Wallet) GetDebitIn

func (w *Wallet) GetDebitIn(in *txin.TxIn, filter uint8) amount.Amount

func (*Wallet) GetDebitTx

func (w *Wallet) GetDebitTx(walletTx *WalletTx, filter uint8) amount.Amount

func (*Wallet) GetMinimumFee

func (w *Wallet) GetMinimumFee(byteSize int) int64

func (*Wallet) GetReservedKey

func (w *Wallet) GetReservedKey() (*crypto.PublicKey, error)

func (*Wallet) GetUnspentCoin

func (w *Wallet) GetUnspentCoin(outPoint *outpoint.OutPoint) *utxo.Coin

func (*Wallet) GetWalletTx

func (w *Wallet) GetWalletTx(txhash util.Hash) *WalletTx

func (*Wallet) GetWalletTxns

func (w *Wallet) GetWalletTxns() []*WalletTx

func (*Wallet) HandleRelatedMempoolTx

func (w *Wallet) HandleRelatedMempoolTx(txe *tx.Tx)

func (*Wallet) Init

func (w *Wallet) Init() error

func (*Wallet) IsEnable

func (w *Wallet) IsEnable() bool

func (*Wallet) IsMine

func (w *Wallet) IsMine(out *txout.TxOut) uint8

func (*Wallet) IsTrusted

func (w *Wallet) IsTrusted(walletTx *WalletTx) bool

func (*Wallet) MarkSpent

func (w *Wallet) MarkSpent(outPoint *outpoint.OutPoint)

func (*Wallet) RemoveFromWallet

func (w *Wallet) RemoveFromWallet(txn *tx.Tx) error

func (*Wallet) SetAddressBook

func (w *Wallet) SetAddressBook(keyHash []byte, account string, purpose string) error

func (*Wallet) SetBroadcastTx

func (w *Wallet) SetBroadcastTx(broadcastTx bool)

func (*Wallet) SetFeeRate

func (w *Wallet) SetFeeRate(feePaid int64, byteSize int64)

type WalletDB

type WalletDB struct {
	*db.DBWrapper
}

type WalletTx

type WalletTx struct {
	*tx.Tx

	ExtInfo map[string]string

	TimeReceived int64

	/**
	 * FromMe flag is set to true for transactions that were created by the wallet
	 * on this bitcoin node, and set to 0 for transactions that were created
	 * externally and came in through the network or sendrawtransaction RPC.
	 */
	IsFromMe bool

	FromAccount string
	// contains filtered or unexported fields
}

func NewEmptyWalletTx

func NewEmptyWalletTx() *WalletTx

func NewWalletTx

func NewWalletTx(txn *tx.Tx, blockhash util.Hash, extInfo map[string]string, isFromMe bool, account string) *WalletTx

func (*WalletTx) CheckFinalForForCurrentBlock

func (wtx *WalletTx) CheckFinalForForCurrentBlock() bool

func (*WalletTx) GetAvailableCredit

func (wtx *WalletTx) GetAvailableCredit(useCache bool) amount.Amount

func (*WalletTx) GetBlokHeight

func (wtx *WalletTx) GetBlokHeight() int32

func (*WalletTx) GetCredit

func (wtx *WalletTx) GetCredit(filter uint8) amount.Amount

func (*WalletTx) GetDebit

func (wtx *WalletTx) GetDebit(filter uint8) amount.Amount

func (*WalletTx) GetDepthInMainChain

func (wtx *WalletTx) GetDepthInMainChain() int32

func (*WalletTx) GetUnspentCoin

func (wtx *WalletTx) GetUnspentCoin(index int) *utxo.Coin

func (*WalletTx) MarkSpent

func (wtx *WalletTx) MarkSpent(index int)

func (*WalletTx) Serialize

func (wtx *WalletTx) Serialize(writer io.Writer) error

func (*WalletTx) SerializeSize

func (wtx *WalletTx) SerializeSize() int

func (*WalletTx) Unserialize

func (wtx *WalletTx) Unserialize(reader io.Reader) error

Jump to

Keyboard shortcuts

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