5 #ifndef BITCOIN_INTERFACES_WALLET_H 6 #define BITCOIN_INTERFACES_WALLET_H 47 struct WalletBalances;
50 struct WalletTxStatus;
67 virtual bool lock() = 0;
84 virtual bool backupWallet(
const std::string &filename) = 0;
93 virtual std::set<CTxDestination>
98 const std::string label,
108 std::string &str_sig) = 0;
118 const std::string &
name,
119 const std::string &purpose) = 0;
126 isminetype *is_mine, std::string *purpose) = 0;
133 const std::string &value) = 0;
137 const std::string &key) = 0;
140 virtual std::vector<std::string>
159 int &change_pos,
Amount &fee,
184 int &num_blocks, int64_t &block_time) = 0;
190 bool &in_mempool,
int &num_blocks) = 0;
196 bool &complete)
const = 0;
203 bool force,
int cached_num_blocks) = 0;
226 std::vector<std::tuple<COutPoint, WalletTxOut>>>;
230 virtual std::vector<WalletTxOut>
231 getCoins(
const std::vector<COutPoint> &outputs) = 0;
259 virtual void remove() = 0;
270 std::function<void(const std::string &title, int progress)>;
275 virtual std::unique_ptr<Handler>
280 const CTxDestination &address,
const std::string &label,
bool is_mine,
282 virtual std::unique_ptr<Handler>
287 std::function<void(const TxId &txid, ChangeType status)>;
288 virtual std::unique_ptr<Handler>
293 virtual std::unique_ptr<Handler>
298 virtual std::unique_ptr<Handler>
313 std::string nameIn, std::string purposeIn)
314 : dest(
std::move(destIn)), is_mine(isMineIn), name(
std::move(nameIn)),
315 purpose(
std::move(purposeIn)) {}
323 bool have_watch_only =
false;
329 return balance != prev.
balance ||
333 unconfirmed_watch_only_balance !=
372 int depth_in_main_chain = -1;
373 bool is_spent =
false;
382 #endif // BITCOIN_INTERFACES_WALLET_H std::shared_ptr< const CTransaction > CTransactionRef
virtual bool isCrypted()=0
Return whether wallet is encrypted.
virtual bool privateKeysDisabled()=0
virtual Amount getRequiredFee(unsigned int tx_bytes)=0
Get required fee.
std::function< void(const std::string &title, int progress)> ShowProgressFn
Register handler for show progress messages.
virtual bool getAddress(const CTxDestination &dest, std::string *name, isminetype *is_mine, std::string *purpose)=0
Look up address in wallet, return whether exists.
virtual CoinsList listCoins()=0
Amount unconfirmed_balance
static constexpr Amount zero()
std::vector< CTxDestination > txout_address
virtual bool isLocked()=0
Return whether wallet is locked.
virtual OutputType getDefaultAddressType()=0
unsigned int time_received
virtual isminetype txoutIsMine(const CTxOut &txout)=0
Return whether transaction output belongs to wallet.
std::function< void(bool have_watch_only)> WatchOnlyChangedFn
Register handler for watchonly changed messages.
virtual CWallet * wallet()
Return pointer to internal wallet class, useful for testing.
Amount unconfirmed_watch_only_balance
std::vector< isminetype > txin_is_mine
virtual std::unique_ptr< Handler > handleAddressBookChanged(AddressBookChangedFn fn)=0
std::vector< isminetype > txout_is_mine
virtual bool getPubKey(const CScript &script, const CKeyID &address, CPubKey &pub_key)=0
Get public key.
std::function< void()> UnloadFn
Register handler for unload message.
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
virtual CTransactionRef createTransaction(const std::vector< CRecipient > &recipients, const CCoinControl &coin_control, bool sign, int &change_pos, Amount &fee, bilingual_str &fail_reason)=0
Create transaction.
virtual std::unique_ptr< Handler > handleWatchOnlyChanged(WatchOnlyChangedFn fn)=0
virtual bool backupWallet(const std::string &filename)=0
Back up wallet.
std::function< void()> CanGetAddressesChangedFn
Register handler for keypool changed messages.
virtual void lockCoin(const COutPoint &output)=0
Lock coin.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system...
A version of CTransaction with the PSBT format.
virtual Amount getAvailableBalance(const CCoinControl &coin_control)=0
Get available balance.
virtual bool transactionCanBeAbandoned(const TxId &txid)=0
Return whether transaction can be abandoned.
std::map< std::string, std::string > WalletValueMap
virtual bool isLegacy()=0
Return whether is a legacy wallet.
virtual SigningResult signMessage(const std::string &message, const PKHash &pkhash, std::string &str_sig)=0
Sign message.
virtual bool eraseDestData(const CTxDestination &dest, const std::string &key)=0
Erase dest data.
virtual bool changeWalletPassphrase(const SecureString &old_wallet_passphrase, const SecureString &new_wallet_passphrase)=0
Change wallet passphrase.
virtual bool isSpendable(const CTxDestination &dest)=0
Return whether wallet has private key.
virtual OutputType getDefaultChangeType()=0
std::function< void()> StatusChangedFn
Register handler for status changed messages.
virtual Amount getDebit(const CTxIn &txin, isminefilter filter)=0
Return debit amount if transaction input belongs to wallet.
virtual isminetype txinIsMine(const CTxIn &txin)=0
Return whether transaction input belongs to wallet.
std::map< CTxDestination, std::vector< std::tuple< COutPoint, WalletTxOut > >> CoinsList
Return AvailableCoins + LockedCoins grouped by wallet address.
virtual std::unique_ptr< Handler > handleUnload(UnloadFn fn)=0
virtual std::set< CTxDestination > getLabelAddresses(const std::string &label)=0
Get set of addresses corresponding to a given label.
virtual std::unique_ptr< Handler > handleTransactionChanged(TransactionChangedFn fn)=0
virtual bool hdEnabled()=0
virtual bool tryGetBalances(WalletBalances &balances, int &num_blocks, bool force, int cached_num_blocks)=0
Get balances if possible without waiting for chain and wallet locks.
virtual std::unique_ptr< Handler > handleShowProgress(ShowProgressFn fn)=0
virtual std::unique_ptr< Handler > handleCanGetAddressesChanged(CanGetAddressesChangedFn fn)=0
virtual std::unique_ptr< Handler > handleStatusChanged(StatusChangedFn fn)=0
virtual void unlockCoin(const COutPoint &output)=0
Unlock coin.
virtual bool abandonTransaction(const TxId &txid)=0
Abandon transaction.
Collection of wallet balances.
An input of a transaction.
virtual Amount getMinimumFee(unsigned int tx_bytes, const CCoinControl &coin_control)=0
Get minimum fee.
virtual CTransactionRef getTx(const TxId &txid)=0
Get a transaction.
An encapsulated public key.
Amount watch_only_balance
std::function< void(const CTxDestination &address, const std::string &label, bool is_mine, const std::string &purpose, ChangeType status)> AddressBookChangedFn
Register handler for address book changed messages.
Interface for accessing a wallet.
virtual bool encryptWallet(const SecureString &wallet_passphrase)=0
Encrypt wallet.
virtual Amount getCredit(const CTxOut &txout, isminefilter filter)=0
Return credit amount if transaction input belongs to wallet.
isminetype
IsMine() return codes.
virtual bool tryGetTxStatus(const TxId &txid, WalletTxStatus &tx_status, int &num_blocks, int64_t &block_time)=0
Try to get updated status for a particular transaction, if possible without blocking.
An output of a transaction.
virtual WalletTx getWalletTxDetails(const TxId &txid, WalletTxStatus &tx_status, WalletOrderForm &order_form, bool &in_mempool, int &num_blocks)=0
Get transaction details.
An outpoint - a combination of a transaction hash and an index n into its vout.
virtual WalletTx getWalletTx(const TxId &txid)=0
Get transaction information.
std::unique_ptr< Wallet > MakeWallet(const std::shared_ptr< CWallet > &wallet)
Return implementation of Wallet interface.
virtual std::vector< WalletTxOut > getCoins(const std::vector< COutPoint > &outputs)=0
Return wallet transaction output information.
virtual bool addDestData(const CTxDestination &dest, const std::string &key, const std::string &value)=0
Add dest data.
virtual bool getNewDestination(const OutputType type, const std::string label, CTxDestination &dest)=0
virtual const CChainParams & getChainParams()=0
Get chainparams.
std::vector< isminetype > txout_address_is_mine
virtual std::vector< WalletTx > getWalletTxs()=0
Get list of all wallet transactions.
virtual bool delAddressBook(const CTxDestination &dest)=0
virtual void listLockedCoins(std::vector< COutPoint > &outputs)=0
List locked coins.
virtual TransactionError fillPSBT(SigHashType sighash_type, bool sign, bool bip32derivs, PartiallySignedTransaction &psbtx, bool &complete) const =0
Fill PSBT.
Serialized script, used inside transaction inputs and outputs.
A TxId is the identifier of a transaction.
Amount immature_watch_only_balance
virtual bool setAddressBook(const CTxDestination &dest, const std::string &name, const std::string &purpose)=0
Add or update address.
A mutable version of CTransaction.
A reference to a CKey: the Hash160 of its serialized public key.
virtual bool haveWatchOnly()=0
Return whether wallet has watch only keys.
WalletAddress(CTxDestination destIn, isminetype isMineIn, std::string nameIn, std::string purposeIn)
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
virtual bool isLockedCoin(const COutPoint &output)=0
Return whether coin is locked.
virtual Amount getDefaultMaxTxFee()=0
Get max tx fee.
std::vector< std::pair< std::string, std::string > > WalletOrderForm
Information about one wallet address.
virtual bool lock()=0
Lock wallet.
std::map< std::string, std::string > value_map
An encapsulated secp256k1 private key.
virtual void abortRescan()=0
Abort a rescan.
The basic transaction that is broadcasted on the network and contained in blocks. ...
virtual void commitTransaction(CTransactionRef tx, WalletValueMap value_map, WalletOrderForm order_form)=0
Commit transaction.
virtual WalletBalances getBalances()=0
Get balances.
ChangeType
General change type (added, updated, removed).
virtual Amount getBalance()=0
Get balance.
Wallet transaction output.
bool balanceChanged(const WalletBalances &prev) const
std::function< void(const TxId &txid, ChangeType status)> TransactionChangedFn
Register handler for transaction changed messages.
virtual std::string getWalletName()=0
Get wallet name.
Updated transaction status.
boost::variant< CNoDestination, PKHash, ScriptHash > CTxDestination
A txout script template with a specific destination.
virtual bool canGetAddresses() const =0
virtual std::vector< std::string > getDestValues(const std::string &prefix)=0
Get dest values with prefix.
Signature hash type wrapper class.
virtual bool unlock(const SecureString &wallet_passphrase)=0
Unlock wallet.
virtual std::vector< WalletAddress > getAddresses()=0
Get wallet address list.