Documentation
¶
Index ¶
- Constants
- Variables
- type NotificationListener
- type RPCWallet
- func (w *RPCWallet) AddTransactionListener(callback func(wallet.TransactionCallback))
- func (w *RPCWallet) AddWatchedAddress(addr btc.Address) error
- func (w *RPCWallet) AddressToScript(addr btc.Address) ([]byte, error)
- func (w *RPCWallet) Balance() (confirmed, unconfirmed int64)
- func (w *RPCWallet) Broadcast(tx *wire.MsgTx) error
- func (w *RPCWallet) BumpFee(txid chainhash.Hash) (*chainhash.Hash, error)
- func (w *RPCWallet) ChainTip() (uint32, chainhash.Hash)
- func (w *RPCWallet) ChildKey(keyBytes []byte, chaincode []byte, isPrivateKey bool) (*hd.ExtendedKey, error)
- func (w *RPCWallet) Close()
- func (w *RPCWallet) CreateMultisigSignature(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, ...) ([]wallet.Signature, error)
- func (w *RPCWallet) CurrencyCode() string
- func (w *RPCWallet) CurrentAddress(purpose wallet.KeyPurpose) btc.Address
- func (w *RPCWallet) DecodeAddress(addr string) (btc.Address, error)
- func (w *RPCWallet) EstimateFee(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, ...) uint64
- func (w *RPCWallet) EstimateSpendFee(amount int64, feeLevel wallet.FeeLevel) (uint64, error)
- func (w *RPCWallet) GenerateMultisigScript(keys []hd.ExtendedKey, threshold int, timeout time.Duration, ...) (addr btc.Address, redeemScript []byte, err error)
- func (w *RPCWallet) GetConfirmations(txid chainhash.Hash) (uint32, uint32, error)
- func (w *RPCWallet) GetFeePerByte(feeLevel wallet.FeeLevel) uint64
- func (w *RPCWallet) GetKey(addr btc.Address) (*btcec.PrivateKey, error)
- func (w *RPCWallet) GetTransaction(txid chainhash.Hash) (wallet.Txn, error)
- func (w *RPCWallet) HasKey(addr btc.Address) bool
- func (w *RPCWallet) IsDust(amount int64) bool
- func (w *RPCWallet) ListAddresses() []btc.Address
- func (w *RPCWallet) ListKeys() []btcec.PrivateKey
- func (w *RPCWallet) MasterPrivateKey() *hd.ExtendedKey
- func (w *RPCWallet) MasterPublicKey() *hd.ExtendedKey
- func (w *RPCWallet) Mnemonic() string
- func (w *RPCWallet) Multisign(ins []wallet.TransactionInput, outs []wallet.TransactionOutput, ...) ([]byte, error)
- func (w *RPCWallet) NewAddress(purpose wallet.KeyPurpose) btc.Address
- func (w *RPCWallet) Params() *chaincfg.Params
- func (w *RPCWallet) ReSyncBlockchain(fromDate time.Time)
- func (w *RPCWallet) RetrieveTransactions() error
- func (w *RPCWallet) ScriptToAddress(script []byte) (btc.Address, error)
- func (w *RPCWallet) Spend(amount int64, addr btc.Address, feeLevel wallet.FeeLevel) (*chainhash.Hash, error)
- func (w *RPCWallet) Start()
- func (w *RPCWallet) SweepAddress(ins []wallet.TransactionInput, address *btc.Address, key *hd.ExtendedKey, ...) (*chainhash.Hash, error)
- func (w *RPCWallet) Transactions() ([]wallet.Txn, error)
- type ReceivedTx
- type TxStore
- func (ts *TxStore) CheckDoubleSpends(argTx *wire.MsgTx) ([]*chainhash.Hash, error)
- func (ts *TxStore) GetPendingInv() (*wire.MsgInv, error)
- func (ts *TxStore) GimmeFilter() (*bloom.Filter, error)
- func (ts *TxStore) Ingest(tx *wire.MsgTx, height int32, timestamp time.Time) (uint32, error)
- func (ts *TxStore) PopulateAdrs() error
Constants ¶
const (
// Account is the name for the Bitcoin wallet account
Account = "OpenBazaar"
)
Variables ¶
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 (*RPCWallet) AddressToScript ¶ added in v1.1.0
AddressToScript returns the script for a given address
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
CurrencyCode returns the currency code of the wallet
func (*RPCWallet) CurrentAddress ¶ added in v1.1.0
CurrentAddress returns an unused address
func (*RPCWallet) DecodeAddress ¶ added in v1.1.0
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
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
GetConfirmations returns the number of confirmations and the block number where the transaction was confirmed
func (*RPCWallet) GetFeePerByte ¶ added in v1.1.0
GetFeePerByte gets the fee in pSAT per byte
func (*RPCWallet) GetTransaction ¶ added in v1.1.0
GetTransaction returns the transaction given by a transaction hash
func (*RPCWallet) HasKey ¶ added in v1.1.0
HasKey returns true if we have the private key for a given address
func (*RPCWallet) ListAddresses ¶ added in v1.1.0
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
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
NewAddress creates a new address
func (*RPCWallet) ReSyncBlockchain ¶ added in v1.1.0
ReSyncBlockchain resyncs the addresses used by the SPV wallet
func (*RPCWallet) RetrieveTransactions ¶ added in v1.1.0
RetrieveTransactions fetches transactions from the rpc server and stores them into the database
func (*RPCWallet) ScriptToAddress ¶ added in v1.1.0
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) 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
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
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
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
GimmeFilter generates a filter from our current used addresses
func (*TxStore) Ingest ¶ added in v1.1.0
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
PopulateAdrs just puts a bunch of adrs in ram; it doesn't touch the DB