phored

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Account is the name for the Bitcoin wallet account
	Account = "OpenBazaar"
)

Variables

View Source
var LookAheadDistance = 5

LookAheadDistance is the number of addresses to look for transactions before assuming the rest are unused

Functions

This section is empty.

Types

type NotificationListener

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

NotificationListener listens for any transactions

type RPCWallet added in v1.1.0

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

RPCWallet represents a wallet based on JSON-RPC and Bitcoind

func NewRPCWallet added in v1.1.0

func NewRPCWallet(mnemonic string, params *chaincfg.Params, repoPath string, DB wallet.Datastore, host string) (*RPCWallet, error)

NewRPCWallet creates a new wallet given

func (*RPCWallet) AddTransactionListener added in v1.1.0

func (w *RPCWallet) AddTransactionListener(callback func(wallet.TransactionCallback))

AddTransactionListener adds a listener for any wallet transactions

func (*RPCWallet) AddWatchedAddress added in v1.3.1

func (w *RPCWallet) AddWatchedAddress(addr btc.Address) error

func (*RPCWallet) AddressToScript added in v1.1.0

func (w *RPCWallet) AddressToScript(addr btc.Address) ([]byte, error)

AddressToScript returns the script for a given address

func (*RPCWallet) Balance added in v1.1.0

func (w *RPCWallet) Balance() (confirmed, unconfirmed int64)

Balance returns the total balance of our addresses

func (*RPCWallet) Broadcast added in v1.1.0

func (w *RPCWallet) Broadcast(tx *wire.MsgTx) error

Broadcast a transaction to the network

func (*RPCWallet) BumpFee added in v1.1.0

func (w *RPCWallet) BumpFee(txid chainhash.Hash) (*chainhash.Hash, error)

BumpFee attempts to bump the fee for a transaction

func (*RPCWallet) ChainTip added in v1.1.0

func (w *RPCWallet) ChainTip() (uint32, chainhash.Hash)

ChainTip returns the tip of the active blockchain

func (*RPCWallet) ChildKey added in v1.3.1

func (w *RPCWallet) ChildKey(keyBytes []byte, chaincode []byte, isPrivateKey bool) (*hd.ExtendedKey, error)

func (*RPCWallet) Close added in v1.1.0

func (w *RPCWallet) Close()

Close closes the rpc wallet connection

func (*RPCWallet) CreateMultisigSignature added in v1.1.0

func (w *RPCWallet) CreateMultisigSignature(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, key *hd.ExtendedKey, redeemScript []byte, feePerByte uint64) ([]wallet.Signature, error)

CreateMultisigSignature creates a multisig signature given the transaction inputs and outputs and the keys

func (*RPCWallet) CurrencyCode added in v1.1.0

func (w *RPCWallet) CurrencyCode() string

CurrencyCode returns the currency code of the wallet

func (*RPCWallet) CurrentAddress added in v1.1.0

func (w *RPCWallet) CurrentAddress(purpose wallet.KeyPurpose) btc.Address

CurrentAddress returns an unused address

func (*RPCWallet) DecodeAddress added in v1.1.0

func (w *RPCWallet) DecodeAddress(addr string) (btc.Address, error)

DecodeAddress decodes an address string to an address using the wallet's chain parameters

func (*RPCWallet) EstimateFee added in v1.1.0

func (w *RPCWallet) EstimateFee(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, feePerByte uint64) uint64

EstimateFee estimates the fee of a transaction

func (*RPCWallet) EstimateSpendFee added in v1.1.0

func (w *RPCWallet) EstimateSpendFee(amount int64, feeLevel wallet.FeeLevel) (uint64, error)

EstimateSpendFee builds a spend transaction for the amount and return the transaction fee

func (*RPCWallet) GenerateMultisigScript added in v1.1.0

func (w *RPCWallet) GenerateMultisigScript(keys []hd.ExtendedKey, threshold int, timeout time.Duration, timeoutKey *hd.ExtendedKey) (addr btc.Address, redeemScript []byte, err error)

GenerateMultisigScript generates a script representing a multisig wallet

func (*RPCWallet) GetConfirmations added in v1.1.0

func (w *RPCWallet) GetConfirmations(txid chainhash.Hash) (uint32, uint32, error)

GetConfirmations returns the number of confirmations and the block number where the transaction was confirmed

func (*RPCWallet) GetFeePerByte added in v1.1.0

func (w *RPCWallet) GetFeePerByte(feeLevel wallet.FeeLevel) uint64

GetFeePerByte gets the fee in pSAT per byte

func (*RPCWallet) GetKey added in v1.1.0

func (w *RPCWallet) GetKey(addr btc.Address) (*btcec.PrivateKey, error)

GetKey gets the private key for a certain address

func (*RPCWallet) GetTransaction added in v1.1.0

func (w *RPCWallet) GetTransaction(txid chainhash.Hash) (wallet.Txn, error)

GetTransaction returns the transaction given by a transaction hash

func (*RPCWallet) HasKey added in v1.1.0

func (w *RPCWallet) HasKey(addr btc.Address) bool

HasKey returns true if we have the private key for a given address

func (*RPCWallet) IsDust added in v1.1.0

func (w *RPCWallet) IsDust(amount int64) bool

IsDust determines if an amount is considered dust

func (*RPCWallet) ListAddresses added in v1.1.0

func (w *RPCWallet) ListAddresses() []btc.Address

ListAddresses lists our currently used addresses

func (*RPCWallet) ListKeys added in v1.1.0

func (w *RPCWallet) ListKeys() []btcec.PrivateKey

ListKeys lists our currently used keys

func (*RPCWallet) MasterPrivateKey added in v1.1.0

func (w *RPCWallet) MasterPrivateKey() *hd.ExtendedKey

MasterPrivateKey returns the wallet's master private key

func (*RPCWallet) MasterPublicKey added in v1.1.0

func (w *RPCWallet) MasterPublicKey() *hd.ExtendedKey

MasterPublicKey returns the wallet's key used to derive public keys

func (*RPCWallet) Mnemonic added in v1.1.0

func (w *RPCWallet) Mnemonic() string

Mnemonic returns the mnemonic used to generate the wallet

func (*RPCWallet) Multisign added in v1.1.0

func (w *RPCWallet) Multisign(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, sigs1 []wallet.Signature, sigs2 []wallet.Signature, redeemScript []byte, feePerByte uint64, broadcast bool) ([]byte, error)

Multisign signs a multisig transaction

func (*RPCWallet) NewAddress added in v1.1.0

func (w *RPCWallet) NewAddress(purpose wallet.KeyPurpose) btc.Address

NewAddress creates a new address

func (*RPCWallet) Params added in v1.1.0

func (w *RPCWallet) Params() *chaincfg.Params

Params returns the current wallet's chain params

func (*RPCWallet) ReSyncBlockchain added in v1.1.0

func (w *RPCWallet) ReSyncBlockchain(fromDate time.Time)

ReSyncBlockchain resyncs the addresses used by the SPV wallet

func (*RPCWallet) RetrieveTransactions added in v1.1.0

func (w *RPCWallet) RetrieveTransactions() error

RetrieveTransactions fetches transactions from the rpc server and stores them into the database

func (*RPCWallet) ScriptToAddress added in v1.1.0

func (w *RPCWallet) ScriptToAddress(script []byte) (btc.Address, error)

ScriptToAddress converts a script to an address

func (*RPCWallet) Spend added in v1.1.0

func (w *RPCWallet) Spend(amount int64, addr btc.Address, feeLevel wallet.FeeLevel) (*chainhash.Hash, error)

Spend spends an amount from an address with a given fee level

func (*RPCWallet) Start added in v1.1.0

func (w *RPCWallet) Start()

Start sets up the rpc wallet

func (*RPCWallet) SweepAddress added in v1.1.0

func (w *RPCWallet) SweepAddress(ins []wallet.TransactionInput, address *btc.Address, key *hd.ExtendedKey, redeemScript *[]byte, feeLevel wallet.FeeLevel) (*chainhash.Hash, error)

SweepAddress sweeps any UTXOs from an address in a single transaction

func (*RPCWallet) Transactions added in v1.1.0

func (w *RPCWallet) Transactions() ([]wallet.Txn, error)

Transactions returns all of the transactions relating to any of our addresses

type ReceivedTx

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

type TxStore added in v1.1.0

type TxStore struct {
	wallet.Datastore
	// contains filtered or unexported fields
}

TxStore handles transactions we've sent and our addresses

func NewTxStore added in v1.1.0

func NewTxStore(p *chaincfg.Params, db wallet.Datastore, keyManager *spvwallet.KeyManager) (*TxStore, error)

NewTxStore creates a new tx store from the given chain parameters, database, and key manager

func (*TxStore) CheckDoubleSpends added in v1.1.0

func (ts *TxStore) CheckDoubleSpends(argTx *wire.MsgTx) ([]*chainhash.Hash, error)

CheckDoubleSpends takes a transaction and compares it with all transactions in the db. It returns a slice of all txids in the db which are double spent by the received tx.

func (*TxStore) GetPendingInv added in v1.1.0

func (ts *TxStore) GetPendingInv() (*wire.MsgInv, error)

GetPendingInv returns an inv message containing all txs known to the db which are at height 0 (not known to be confirmed). This can be useful on startup or to rebroadcast unconfirmed txs.

func (*TxStore) GimmeFilter added in v1.1.0

func (ts *TxStore) GimmeFilter() (*bloom.Filter, error)

GimmeFilter generates a filter from our current used addresses

func (*TxStore) Ingest added in v1.1.0

func (ts *TxStore) Ingest(tx *wire.MsgTx, height int32, timestamp time.Time) (uint32, error)

Ingest puts a tx into the DB atomically. This can result in a gain, a loss, or no result. Gain or loss in satoshis is returned.

func (*TxStore) PopulateAdrs added in v1.1.0

func (ts *TxStore) PopulateAdrs() error

PopulateAdrs just puts a bunch of adrs in ram; it doesn't touch the DB

Jump to

Keyboard shortcuts

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