Skip to content

Commit 55a2dd9

Browse files
feat(#571): add userParty as wallet name (#689)
1 parent 04ad236 commit 55a2dd9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pkg/wallet/wallet.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ type Wallet struct {
5151
pendingSignActionsCache pending.SignActionsRepository
5252
logger *slog.Logger
5353
cleanup walletCleanupFunc
54+
userParty string
5455
}
5556

5657
// WithIncludeAllSourceTransactions - default: `true`
@@ -139,12 +140,6 @@ func NewWithStorageFactory[KeySource PrivateKeySource, ActiveStorageFactory Stor
139140
PendingSignActionsRepo: nil,
140141
}, opts...)
141142

142-
logger := logging.Child(options.Logger, "wallet")
143-
144-
if options.PendingSignActionsRepo == nil {
145-
options.PendingSignActionsRepo = pending.NewSignActionLocalRepository(logger, pending.DefaultPendingSignActionsTTL)
146-
}
147-
148143
keyDeriver, err := toKeyDeriver(keySource)
149144
if err != nil {
150145
return nil, fmt.Errorf("failed to create key deriver from key source: %w", err)
@@ -155,6 +150,13 @@ func NewWithStorageFactory[KeySource PrivateKeySource, ActiveStorageFactory Stor
155150
return nil, fmt.Errorf("failed to create proto wallet: %w", err)
156151
}
157152

153+
userParty := fmt.Sprintf("user %s", keyDeriver.IdentityKey().ToDERHex())
154+
logger := logging.Child(options.Logger, "wallet").With("walletName", userParty)
155+
156+
if options.PendingSignActionsRepo == nil {
157+
options.PendingSignActionsRepo = pending.NewSignActionLocalRepository(logger, pending.DefaultPendingSignActionsTTL)
158+
}
159+
158160
w := &Wallet{
159161
proto: proto,
160162
keyDeriver: keyDeriver,
@@ -163,6 +165,7 @@ func NewWithStorageFactory[KeySource PrivateKeySource, ActiveStorageFactory Stor
163165
chain: chain,
164166
pendingSignActionsCache: options.PendingSignActionsRepo,
165167
logger: logger,
168+
userParty: userParty,
166169
}
167170

168171
activeStorage, storageCleanup, err := toStorageProvider(w, activeStorageFactory)

0 commit comments

Comments
 (0)