rpcserver: populate wallet_synced in GetInfo response
What changed, and why it matters
This commit is a small internal code cleanup in LND's GetInfo RPC. It adds a separate field to track whether the wallet is synced to the blockchain, but currently that field mirrors the existing overall sync status. There is no security issue visible in the change.
No security action required. Review as normal code-quality change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch extends chainSyncInfo with an isWalletSynced field and populates the WalletSynced field in the GetInfo RPC response from it. Currently isWalletSynced is assigned the same value as the existing isSynced because both come from Wallet.IsSynced(). The composite isSynced may later also incorporate the router’s synced height. This is preparatory plumbing and does not change behavior or introduce a vulnerability.
Changed components
rpcserver.go GetInfo RPC handlerchainSyncInfo structInspect captured patch +14 / −7
diff --git a/rpcserver.go b/rpcserver.go
index e5d59a3..fe0e670 100644
--- a/rpcserver.go
+++ b/rpcserver.go
@@ -3450,6 +3450,7 @@ func (r *rpcServer) GetInfo(_ context.Context,
Features: features,
RequireHtlcInterceptor: r.cfg.RequireInterceptor,
StoreFinalHtlcResolutions: r.cfg.StoreFinalHtlcResolutions,
+ WalletSynced: syncInfo.isWalletSynced,
}, nil
}
@@ -9468,6 +9469,10 @@ type chainSyncInfo struct {
// - blockbeat dispatcher.
isSynced bool
+ // isWalletSynced specifies whether the wallet is synced to
+ // our chain view.
+ isWalletSynced bool
+
// bestHeight is the current height known to the chain backend.
bestHeight int32
@@ -9488,22 +9493,23 @@ func (r *rpcServer) getChainSyncInfo() (*chainSyncInfo, error) {
return nil, fmt.Errorf("unable to get best block info: %w", err)
}
- isSynced, bestHeaderTimestamp, err := r.server.cc.Wallet.IsSynced()
+ isWalletSynced, bestHeaderTimestamp, err :=
+ r.server.cc.Wallet.IsSynced()
if err != nil {
return nil, fmt.Errorf("unable to sync PoV of the wallet "+
"with current best block in the main chain: %v", err)
}
- // Create an info to be returned.
+ // Create info to be returned.
info := &chainSyncInfo{
- isSynced: isSynced,
- bestHeight: bestHeight,
- blockHash: *bestHash,
- timestamp: bestHeaderTimestamp,
+ isWalletSynced: isWalletSynced,
+ bestHeight: bestHeight,
+ blockHash: *bestHash,
+ timestamp: bestHeaderTimestamp,
}
// Exit early if the wallet is not synced.
- if !isSynced {
+ if !isWalletSynced {
rpcsLog.Debugf("Wallet is not synced to height %v yet",
bestHeight)
@@ -9518,6 +9524,7 @@ func (r *rpcServer) getChainSyncInfo() (*chainSyncInfo, error) {
// by many wallets (and also our itests) to make sure everything's up to
// date, we add the router's state to it. So the flag will only toggle
// to true once the router was also able to catch up.
+ isSynced := isWalletSynced
if !r.cfg.Routing.AssumeChannelValid {
routerHeight := r.server.graphBuilder.SyncedHeight()
isSynced = uint32(bestHeight) == routerHeight
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.