Commit 74c3b9d 1 parent 9b0b464 commit 74c3b9d Copy full SHA for 74c3b9d
File tree 3 files changed +30
-0
lines changed
lib/customer-deposit-wallet/src/Cardano/Wallet/Deposit
3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ module Cardano.Wallet.Deposit.IO
6
6
-- * Types
7
7
WalletEnv (.. )
8
8
, WalletBootEnv (.. )
9
+ , WalletPublicIdentity (.. )
9
10
, WalletInstance
10
11
11
12
-- * Operations
@@ -29,6 +30,7 @@ module Cardano.Wallet.Deposit.IO
29
30
, getBIP32PathsForOwnedInputs
30
31
, signTxBody
31
32
, WalletStore
33
+ , walletPublicIdentity
32
34
) where
33
35
34
36
import Prelude
@@ -193,6 +195,18 @@ createAddress c w =
193
195
let (r,s1) = Wallet. createAddress c s0
194
196
in (Delta. Replace s1, r)
195
197
198
+ data WalletPublicIdentity = WalletPublicIdentity
199
+ { pubXpub :: XPub
200
+ , pubNextUser :: Word31
201
+ }
202
+
203
+ walletPublicIdentity :: WalletInstance -> IO WalletPublicIdentity
204
+ walletPublicIdentity w = do
205
+ state <- readWalletState w
206
+ pure $ WalletPublicIdentity
207
+ { pubXpub = Wallet. walletXPub state
208
+ , pubNextUser = Wallet. nextCustomer state
209
+ }
196
210
{- ----------------------------------------------------------------------------
197
211
Operations
198
212
Reading from the blockchain
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ module Cardano.Wallet.Deposit.Pure
38
38
39
39
, addTxSubmission
40
40
, listTxsInSubmission
41
+ , nextCustomer
42
+ , walletXPub
41
43
) where
42
44
43
45
import Prelude
@@ -83,6 +85,7 @@ import qualified Cardano.Wallet.Deposit.Pure.UTxOHistory as UTxOHistory
83
85
import qualified Cardano.Wallet.Deposit.Read as Read
84
86
import qualified Cardano.Wallet.Deposit.Write as Write
85
87
import qualified Data.Delta as Delta
88
+ import qualified Data.Map as Map
86
89
import qualified Data.Set as Set
87
90
88
91
{- ----------------------------------------------------------------------------
@@ -137,6 +140,12 @@ isCustomerAddress address =
137
140
fromRawCustomer :: Word31 -> Customer
138
141
fromRawCustomer = id
139
142
143
+ nextCustomer :: WalletState -> Customer
144
+ nextCustomer = maybe 0 snd . Map. lookupMax . Address. addresses . addresses
145
+
146
+ walletXPub :: WalletState -> XPub
147
+ walletXPub = Address. getXPub . addresses
148
+
140
149
{- ----------------------------------------------------------------------------
141
150
Operations
142
151
Reading from the blockchain
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ module Cardano.Wallet.Deposit.REST
43
43
, getBIP32PathsForOwnedInputs
44
44
, signTxBody
45
45
, walletExists
46
+ , walletPublicIdentity
46
47
) where
47
48
48
49
import Prelude
@@ -57,6 +58,9 @@ import Cardano.Crypto.Wallet
57
58
import Cardano.Wallet.Address.BIP32
58
59
( BIP32Path
59
60
)
61
+ import Cardano.Wallet.Deposit.IO
62
+ ( WalletPublicIdentity
63
+ )
60
64
import Cardano.Wallet.Deposit.IO.Resource
61
65
( ErrResourceExists (.. )
62
66
, ErrResourceMissing (.. )
@@ -315,6 +319,9 @@ walletExists fp = liftIO $ findTheDepositWalletOnDisk fp $ \case
315
319
Right _ -> pure True
316
320
Left _ -> pure False
317
321
322
+ walletPublicIdentity :: WalletResourceM WalletPublicIdentity
323
+ walletPublicIdentity = onWalletInstance WalletIO. walletPublicIdentity
324
+
318
325
{- ----------------------------------------------------------------------------
319
326
Operations
320
327
------------------------------------------------------------------------------}
You can’t perform that action at this time.
0 commit comments