From c47973ff880cd748a859606b02c5b3548f8ee8bc Mon Sep 17 00:00:00 2001 From: pasta Date: Fri, 6 Nov 2026 01:32:16 -0600 Subject: [PATCH] feat(wallet): list the asset locks that fund Platform from the wallet's own transactions An identity registration or top-up locks coins into a credit output that pays a key derived from the wallet's seed. If Platform has not consumed that lock when the GUI's own records are lost, as after a seed restore, nothing pointed back at it: the GUI would fund a second lock with the same registration key, and top-up credits stayed stranded. listAssetLockFundings(keys) reads that inventory from the transactions the wallet holds, which a restore recovers by rescanning: every credit output of a wallet asset lock that pays one of the given funding keys, with its txid, credit index, key, amount and status. ACTIVE is not abandoned and has no mined conflict; INACTIVE is abandoned and unmined, which can still be mined, so it stays listed; CONFLICTED has a mined conflict. Nothing else is persisted. Deriving the keys needs an unlocked wallet. The status comes from the state the wallet records for the transaction, not from its depth. Depth counts from the last block notification the wallet processed, and a rescan installs mined transactions above it, so a lock it finds two or more blocks higher would have a negative depth and read as conflicted. Co-Authored-By: Claude Opus 5.5 --- src/interfaces/wallet.h | 6 +++ src/wallet/interfaces.cpp | 5 +++ src/wallet/platformtypes.h | 17 ++++++++ src/wallet/test/wallet_tests.cpp | 70 ++++++++++++++++++++++++++++++++ src/wallet/wallet.cpp | 35 ++++++++++++++++ src/wallet/wallet.h | 1 + 6 files changed, 134 insertions(+) diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 7f08ba98b510..332fe36e6399 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -177,6 +177,12 @@ class Wallet virtual wallet::PlatformKeyResult ensureFriendshipReceivingKeychain( const wallet::FriendshipKeychainRequest& request) = 0; + //! Every credit output of this wallet's asset lock transactions that pays + //! one of keys, derived from the transactions the wallet holds. Deriving + //! the keys needs an unlocked wallet. + virtual wallet::PlatformKeyResult> listAssetLockFundings( + const std::vector& keys) = 0; + //! Return whether wallet has private key. virtual bool isSpendable(const CScript& script) = 0; virtual bool isSpendable(const CTxDestination& dest) = 0; diff --git a/src/wallet/interfaces.cpp b/src/wallet/interfaces.cpp index c6d755e9d95d..c1385a5fc200 100644 --- a/src/wallet/interfaces.cpp +++ b/src/wallet/interfaces.cpp @@ -286,6 +286,11 @@ class WalletImpl : public Wallet { return m_wallet->EnsureFriendshipReceivingKeychain(request); } + wallet::PlatformKeyResult> listAssetLockFundings( + const std::vector& keys) override + { + return m_wallet->ListAssetLockFundings(keys); + } bool isSpendable(const CScript& script) override { LOCK(m_wallet->cs_wallet); diff --git a/src/wallet/platformtypes.h b/src/wallet/platformtypes.h index 64aeb0b3f21e..25af37fd1896 100644 --- a/src/wallet/platformtypes.h +++ b/src/wallet/platformtypes.h @@ -5,6 +5,7 @@ #ifndef BITCOIN_WALLET_PLATFORMTYPES_H #define BITCOIN_WALLET_PLATFORMTYPES_H +#include #include #include