Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions darepod/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,21 @@ func (s *Server) RPCAddr() net.Addr {
return s.rpcAddr
}

// GetStoredVTXO returns the persisted VTXO descriptor for the
// given outpoint. This method exists for test harnesses only;
// it lets integration tests inspect locally stored partial
// unroll state without reaching into internal daemon fields.
func (s *Server) GetStoredVTXO(ctx context.Context,
outpoint wire.OutPoint) (*vtxo.Descriptor, error) {

if s.vtxoStore == nil {
return nil, fmt.Errorf("client daemon VTXO " +
"store not initialized")
}

return s.vtxoStore.GetVTXO(ctx, outpoint)
}
Comment on lines +321 to +330

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The access to s.vtxoStore in this method is not thread-safe. Since vtxoStore is initialized within the run method (line 581), which is typically executed in a separate goroutine during integration tests, calling GetStoredVTXO concurrently with the server startup will result in a data race.

To maintain consistency with how other fields like rpcAddr are handled (see RPCAddr() at line 310), consider protecting vtxoStore with a mutex or using an atomic.Pointer for its initialization and access. This ensures that test harnesses can safely call this accessor even if the daemon is still in its startup phase.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say given this is a test only function this is more of a non-issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah - included in comment :)


// RunUntilShutdown starts all subsystems and blocks until the shutdown
// interceptor fires or a fatal error occurs. The startup sequence
// branches on the configured wallet type: in lnd mode, the daemon
Expand Down
Loading