MCPcopy Create free account
hub / github.com/ElementsProject/elements / IsSpentKey

Method IsSpentKey

src/wallet/wallet.cpp:912–945  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

910}
911
912bool CWallet::IsSpentKey(const uint256& hash, unsigned int n) const
913{
914 AssertLockHeld(cs_wallet);
915 const CWalletTx* srctx = GetWalletTx(hash);
916 if (srctx) {
917 assert(srctx->tx->vout.size() > n);
918 CTxDestination dest;
919 if (!ExtractDestination(srctx->tx->vout[n].scriptPubKey, dest)) {
920 return false;
921 }
922 if (IsAddressUsed(dest)) {
923 return true;
924 }
925 if (IsLegacy()) {
926 LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan();
927 assert(spk_man != nullptr);
928 for (const auto& keyid : GetAffectedKeys(srctx->tx->vout[n].scriptPubKey, *spk_man)) {
929 WitnessV0KeyHash wpkh_dest(keyid);
930 if (IsAddressUsed(wpkh_dest)) {
931 return true;
932 }
933 ScriptHash sh_wpkh_dest(GetScriptForDestination(wpkh_dest));
934 if (IsAddressUsed(sh_wpkh_dest)) {
935 return true;
936 }
937 PKHash pkh_dest(keyid);
938 if (IsAddressUsed(pkh_dest)) {
939 return true;
940 }
941 }
942 }
943 }
944 return false;
945}
946
947CWalletTx* CWallet::AddToWallet(CTransactionRef tx, const TxState& state, const UpdateWalletTxFn& update_wtx, bool fFlushOnClose, bool rescanning_old_block)
948{

Callers 3

spend.cppFile · 0.80
listunspentFunction · 0.80

Calls 4

ExtractDestinationFunction · 0.85
GetAffectedKeysFunction · 0.85
GetScriptForDestinationFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected