mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-11 11:16:09 -05:00
![Andrew Chow](/assets/img/avatar_default.png)
a6b0c1fcc0
doc: add releases notes for 25504 (listsinceblock updates) (Antoine Poinsot)0fd2d14454
rpc: add an include_change parameter to listsinceblock (Antoine Poinsot)55f98d087e
rpc: output parent wallet descriptors for coins in listunspent (Antoine Poinsot)b724476158
rpc: output wallet descriptors for received entries in listsinceblock (Antoine Poinsot)55a82eaf91
wallet: allow to fetch the wallet descriptors for a given Script (Antoine Poinsot) Pull request description: Wallet descriptors are useful for applications using the Bitcoin Core wallet as a backend for tracking coins, as they allow to track coins for multiple descriptors in a single wallet. However there is no information currently given for such applications to link a coin with an imported descriptor, severely limiting the possibilities for such applications of using multiple descriptors in a single wallet. This PR outputs the matching imported descriptor(s) for a given received coin in `listsinceblock` (and friends). It comes from a need for an application i'm working on, but i think it's something any software using `bitcoind` to track multiple descriptors in a single wallet would have eventually. For instance i'm thinking about the BDK project. Currently, the way to achieve this is to import raw addresses with labels and to have your application be responsible for wallet things like the gap limit. I'll add this to the output of `listunspent` too if this gets a few Concept ACKs. ACKs for top commit: instagibbs: ACKa6b0c1fcc0
achow101: re-ACKa6b0c1fcc0
Tree-SHA512: 7a5850e8de98b439ddede2cb72de0208944f8cda67272e8b8037678738d55b7a5272375be808b0f7d15def4904430e089dafdcc037436858ff3292c5f8b75e37
65 lines
3.3 KiB
C++
65 lines
3.3 KiB
C++
// Copyright (c) 2021 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#ifndef BITCOIN_WALLET_RECEIVE_H
|
|
#define BITCOIN_WALLET_RECEIVE_H
|
|
|
|
#include <consensus/amount.h>
|
|
#include <wallet/ismine.h>
|
|
#include <wallet/transaction.h>
|
|
#include <wallet/wallet.h>
|
|
|
|
namespace wallet {
|
|
isminetype InputIsMine(const CWallet& wallet, const CTxIn& txin) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
|
|
/** Returns whether all of the inputs match the filter */
|
|
bool AllInputsMine(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
|
|
|
|
CAmount OutputGetCredit(const CWallet& wallet, const CTxOut& txout, const isminefilter& filter);
|
|
CAmount TxGetCredit(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
|
|
|
|
bool ScriptIsChange(const CWallet& wallet, const CScript& script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
bool OutputIsChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
CAmount OutputGetChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
CAmount TxGetChange(const CWallet& wallet, const CTransaction& tx);
|
|
|
|
CAmount CachedTxGetCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter)
|
|
EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
//! filter decides which addresses will count towards the debit
|
|
CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
|
|
CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx);
|
|
CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter)
|
|
EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter = ISMINE_SPENDABLE)
|
|
EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
struct COutputEntry
|
|
{
|
|
CTxDestination destination;
|
|
CAmount amount;
|
|
int vout;
|
|
};
|
|
void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
|
|
std::list<COutputEntry>& listReceived,
|
|
std::list<COutputEntry>& listSent,
|
|
CAmount& nFee, const isminefilter& filter,
|
|
bool include_change);
|
|
bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
|
|
bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set<uint256>& trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx);
|
|
|
|
struct Balance {
|
|
CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more
|
|
CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)
|
|
CAmount m_mine_immature{0}; //!< Immature coinbases in the main chain
|
|
CAmount m_watchonly_trusted{0};
|
|
CAmount m_watchonly_untrusted_pending{0};
|
|
CAmount m_watchonly_immature{0};
|
|
};
|
|
Balance GetBalance(const CWallet& wallet, int min_depth = 0, bool avoid_reuse = true);
|
|
|
|
std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet);
|
|
std::set<std::set<CTxDestination>> GetAddressGroupings(const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
|
|
} // namespace wallet
|
|
|
|
#endif // BITCOIN_WALLET_RECEIVE_H
|