From 671fb37f14cc79a26c4f9417642a85921024aa55 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Wed, 11 May 2022 14:54:59 +0200 Subject: [PATCH 01/10] unify how walletid is calculated --- lib/core/src/Cardano/Wallet/Api/Server.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index d6bb23c1d5a..b79aac0b9a6 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -1054,11 +1054,11 @@ postSharedWalletFromRootXPrv ctx generateKey body = do rootXPrv = generateKey (seed, secondFactor) pwdP g = defaultAddressPoolGap ix = getApiT (body ^. #accountIndex) - wid = WalletId $ digest $ publicKey rootXPrv pTemplate = scriptTemplateFromSelf (getRawKey accXPub) $ body ^. #paymentScriptTemplate dTemplateM = scriptTemplateFromSelf (getRawKey accXPub) <$> body ^. #delegationScriptTemplate wName = getApiT (body ^. #name) accXPub = publicKey $ deriveAccountPrivateKey pwdP rootXPrv (Index $ getDerivationIndex ix) + wid = WalletId $ digest accXPub scriptValidation = maybe RecommendedValidation getApiT (body ^. #scriptValidation) postSharedWalletFromAccountXPub From 1e6825c08d4da558687912d653dfa7ec9f3230a2 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Wed, 11 May 2022 17:36:52 +0200 Subject: [PATCH 02/10] add some integration tests comparing wallet id --- .../Scenario/API/Shared/Wallets.hs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs index 3aac19a5f42..cbeba6b9e92 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs @@ -25,6 +25,7 @@ import Cardano.Mnemonic ( MkSomeMnemonic (..) ) import Cardano.Wallet.Api.Types ( ApiAccountKeyShared (..) + , ApiActiveSharedWallet , ApiAddress , ApiFee (..) , ApiSharedWallet (..) @@ -214,6 +215,59 @@ spec = describe "SHARED_WALLETS" $ do let ApiAccountKeyShared bytes' _ _ = getFromResponse id aKey hexText bytes' `shouldBe` accXPubDerived + let (ApiSharedWallet (Right walActive)) = wal + + rDel <- request @ApiActiveSharedWallet ctx + (Link.deleteWallet @'Shared walActive) Default Empty + expectResponseCode HTTP.status204 rDel + + (_, accXPubTxt):_ <- liftIO $ genXPubs 1 + let payloadAcctOther = Json [json| { + "name": "Shared Wallet", + "account_public_key": #{accXPubTxt}, + "account_index": "30H", + "payment_script_template": + { "cosigners": + { "cosigner#0": #{accXPubTxt} }, + "template": + { "all": + [ "cosigner#0", + { "active_from": 120 } + ] + } + } + } |] + rPostAcctOther <- postSharedWallet ctx Default payloadAcctOther + verify (fmap (view #wallet) <$> rPostAcctOther) + [ expectResponseCode HTTP.status201 ] + let walAcctOther = getFromResponse id rPostAcctOther + let (ApiSharedWallet (Right walAcctOtherActive)) = walAcctOther + + (walAcctOtherActive ^. #id) `shouldNotBe` (walActive ^. #id) + + let payloadAcctSame = Json [json| { + "name": "Shared Wallet", + "account_public_key": #{accXPubDerived}, + "account_index": "30H", + "payment_script_template": + { "cosigners": + { "cosigner#0": #{accXPubDerived} }, + "template": + { "all": + [ "cosigner#0", + { "active_from": 120 } + ] + } + } + } |] + rPostAcctSame <- postSharedWallet ctx Default payloadAcctSame + verify (fmap (view #wallet) <$> rPostAcctSame) + [ expectResponseCode HTTP.status201 ] + let walAcctSame = getFromResponse id rPostAcctSame + let (ApiSharedWallet (Right walAcctSameActive)) = walAcctSame + + (walAcctSameActive ^. #id) `shouldBe` (walActive ^. #id) + it "SHARED_WALLETS_CREATE_02 - Create a pending shared wallet from root xprv" $ \ctx -> runResourceT $ do m15txt <- liftIO $ genMnemonics M15 m12txt <- liftIO $ genMnemonics M12 From 27ca435847d39507c64523063d692e14506a4ea0 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 13 May 2022 13:59:40 +0200 Subject: [PATCH 03/10] propose toSharedWalletId calculation --- lib/core/src/Cardano/Wallet/Api/Server.hs | 5 +++-- .../Primitive/AddressDiscovery/Shared.hs | 21 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index b79aac0b9a6..f0ab06b364d 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -416,6 +416,7 @@ import Cardano.Wallet.Primitive.AddressDiscovery.Shared , mkSharedStateFromAccountXPub , mkSharedStateFromRootXPrv , validateScriptTemplates + , toSharedWalletId ) import Cardano.Wallet.Primitive.Delegation.UTxO ( stakeKeyCoinDistr ) @@ -1058,7 +1059,7 @@ postSharedWalletFromRootXPrv ctx generateKey body = do dTemplateM = scriptTemplateFromSelf (getRawKey accXPub) <$> body ^. #delegationScriptTemplate wName = getApiT (body ^. #name) accXPub = publicKey $ deriveAccountPrivateKey pwdP rootXPrv (Index $ getDerivationIndex ix) - wid = WalletId $ digest accXPub + wid = WalletId $ toSharedWalletId accXPub pTemplate dTemplateM scriptValidation = maybe RecommendedValidation getApiT (body ^. #scriptValidation) postSharedWalletFromAccountXPub @@ -1098,7 +1099,7 @@ postSharedWalletFromAccountXPub ctx liftKey body = do wName = getApiT (body ^. #name) (ApiAccountPublicKey accXPubApiT) = body ^. #accountPublicKey accXPub = getApiT accXPubApiT - wid = WalletId $ digest (liftKey accXPub) + wid = WalletId $ toSharedWalletId (liftKey accXPub) pTemplate dTemplateM scriptValidation = maybe RecommendedValidation getApiT (body ^. #scriptValidation) scriptTemplateFromSelf :: XPub -> ApiScriptTemplateEntry -> ScriptTemplate diff --git a/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs b/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs index 4f49ae96e1f..620c8cdbe57 100644 --- a/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs +++ b/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs @@ -40,6 +40,7 @@ module Cardano.Wallet.Primitive.AddressDiscovery.Shared , isShared , retrieveAllCosigners , validateScriptTemplates + , toSharedWalletId , CredentialType (..) , liftPaymentAddress @@ -63,7 +64,7 @@ import Cardano.Address.Script import Cardano.Address.Style.Shelley ( Credential (..), delegationAddress, paymentAddress ) import Cardano.Crypto.Wallet - ( XPrv, XPub ) + ( XPrv, XPub, unXPub ) import Cardano.Wallet.Primitive.AddressDerivation ( Depth (..) , DerivationIndex (..) @@ -108,6 +109,8 @@ import Control.DeepSeq ( NFData ) import Control.Monad ( unless ) +import Crypto.Hash + ( Blake2b_160, Digest, hash ) import Data.Either ( isRight ) import Data.Either.Combinators @@ -134,6 +137,7 @@ import qualified Data.Foldable as F import qualified Data.List.NonEmpty as NE import qualified Data.Map.Strict as Map import qualified Data.Text as T +import qualified Data.Text.Encoding as T -- | Convenient alias for commonly used class contexts on keys. type SupportsDiscovery (n :: NetworkDiscriminant) k = @@ -597,3 +601,18 @@ liftDelegationAddress ix dTemplate (KeyFingerprint fingerprint) = delegationCredential = DelegationFromScript . toScriptHash dScript = replaceCosignersWithVerKeys CA.Stake dTemplate ix + +toSharedWalletId + :: (WalletKey k, k ~ SharedKey) + => k 'AccountK XPub + -> ScriptTemplate + -> Maybe ScriptTemplate + -> Digest Blake2b_160 +toSharedWalletId accXPub pTemplate dTemplateM = + hash $ + (unXPub . getRawKey $ accXPub) <> + toByteString pTemplate <> + maybe mempty toByteString dTemplateM + where + toByteString (ScriptTemplate _ script) = + T.encodeUtf8 $ T.pack $ show $ script From c8a5180ae5b82f0bde62bf8c1ddd9765a60a609c Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Fri, 13 May 2022 14:24:46 +0200 Subject: [PATCH 04/10] add integration test showing script influence on walletid --- .../Scenario/API/Shared/Wallets.hs | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs index cbeba6b9e92..f38bd619d4c 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs @@ -268,6 +268,30 @@ spec = describe "SHARED_WALLETS" $ do (walAcctSameActive ^. #id) `shouldBe` (walActive ^. #id) + let payloadAcctSameOtherScript = Json [json| { + "name": "Shared Wallet", + "account_public_key": #{accXPubDerived}, + "account_index": "30H", + "payment_script_template": + { "cosigners": + { "cosigner#0": #{accXPubDerived} }, + "template": + { "all": + [ "cosigner#0", + { "active_from": 100 } + ] + } + } + } |] + rPostAcctSameOtherScript <- postSharedWallet ctx Default payloadAcctSameOtherScript + verify (fmap (view #wallet) <$> rPostAcctSameOtherScript) + [ expectResponseCode HTTP.status201 ] + let walAcctSameOtherScript = getFromResponse id rPostAcctSameOtherScript + let (ApiSharedWallet (Right walAcctSameOtherScriptActive)) = walAcctSameOtherScript + + (walAcctSameOtherScriptActive ^. #id) `shouldNotBe` (walActive ^. #id) + + it "SHARED_WALLETS_CREATE_02 - Create a pending shared wallet from root xprv" $ \ctx -> runResourceT $ do m15txt <- liftIO $ genMnemonics M15 m12txt <- liftIO $ genMnemonics M12 From ad0c774660ab8a43c8cd0305af8f74d0eb6b61a0 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Tue, 17 May 2022 16:17:09 +0200 Subject: [PATCH 05/10] hint --- .../src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs b/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs index 620c8cdbe57..3265b6d815b 100644 --- a/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs +++ b/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs @@ -615,4 +615,4 @@ toSharedWalletId accXPub pTemplate dTemplateM = maybe mempty toByteString dTemplateM where toByteString (ScriptTemplate _ script) = - T.encodeUtf8 $ T.pack $ show $ script + T.encodeUtf8 $ T.pack $ show script From fe2d896f2328ad43e844361c99f209d4135567fb Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 19 May 2022 12:06:39 +0200 Subject: [PATCH 06/10] add new cardano-address commit reference and nix updates --- nix/materialized/stack-nix/.stack-to-nix.cache | 4 ++-- nix/materialized/stack-nix/.stack-to-nix.cache.0 | 2 +- nix/materialized/stack-nix/.stack-to-nix.cache.1 | 2 +- nix/sha256map.nix | 2 +- stack.yaml | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nix/materialized/stack-nix/.stack-to-nix.cache b/nix/materialized/stack-nix/.stack-to-nix.cache index 8626a341b08..438020c7640 100644 --- a/nix/materialized/stack-nix/.stack-to-nix.cache +++ b/nix/materialized/stack-nix/.stack-to-nix.cache @@ -1,5 +1,5 @@ -https://github.com/input-output-hk/cardano-addresses 8bf98905b903455196495e231b23613ad2264cb0 command-line 0jzlm1gnlbvz9kify2z74v9iydy6vf39nk954r73yaddknhxrq2r cardano-addresses-cli .stack-to-nix.cache.0 -https://github.com/input-output-hk/cardano-addresses 8bf98905b903455196495e231b23613ad2264cb0 core 0jzlm1gnlbvz9kify2z74v9iydy6vf39nk954r73yaddknhxrq2r cardano-addresses .stack-to-nix.cache.1 +https://github.com/input-output-hk/cardano-addresses b33e0f365550bd9d329bdbb0a0d2dfe2b23a3dcf command-line 05vj2fc6n8rmn3ch6115pc6l5vw6pqbv2kwbzxf3y41sa40k50vc cardano-addresses-cli .stack-to-nix.cache.0 +https://github.com/input-output-hk/cardano-addresses b33e0f365550bd9d329bdbb0a0d2dfe2b23a3dcf core 05vj2fc6n8rmn3ch6115pc6l5vw6pqbv2kwbzxf3y41sa40k50vc cardano-addresses .stack-to-nix.cache.1 https://github.com/biocad/servant-openapi3 4165b837d3a71debd1059c3735460075840000b5 . 1dngrr353kjhmwhn0b289jzqz5rf32llwcv79zcyq15ldpqpbib9 servant-openapi3 .stack-to-nix.cache.2 https://github.com/paolino/openapi3 c30d0de6875d75edd64d1aac2272886528bc492d . 0b0fzj5vrnfrc8qikabxhsnp4p8lrjpssblbh2rb7aji5hzzfli9 openapi3 .stack-to-nix.cache.3 https://github.com/input-output-hk/optparse-applicative 7497a29cb998721a9068d5725d49461f2bba0e7a . 1gvsrg925vynwgqwplgjmp53vj953qyh3wbdf34pw21c8r47w35r optparse-applicative-fork .stack-to-nix.cache.4 diff --git a/nix/materialized/stack-nix/.stack-to-nix.cache.0 b/nix/materialized/stack-nix/.stack-to-nix.cache.0 index 66b6c64ff2f..dcca0de499a 100644 --- a/nix/materialized/stack-nix/.stack-to-nix.cache.0 +++ b/nix/materialized/stack-nix/.stack-to-nix.cache.0 @@ -82,5 +82,5 @@ }; }; } // rec { - src = (pkgs.lib).mkDefault /nix/store/ygizp24vac8mm3j4dq59sajld3l4v991-cardano-addresses-8bf9890/command-line; + src = (pkgs.lib).mkDefault /nix/store/mppiglijmgwx201yk20kkcfdx3zp7101-cardano-addresses-b33e0f3/command-line; } diff --git a/nix/materialized/stack-nix/.stack-to-nix.cache.1 b/nix/materialized/stack-nix/.stack-to-nix.cache.1 index 210c3961634..1982f6151a7 100644 --- a/nix/materialized/stack-nix/.stack-to-nix.cache.1 +++ b/nix/materialized/stack-nix/.stack-to-nix.cache.1 @@ -77,5 +77,5 @@ }; }; } // rec { - src = (pkgs.lib).mkDefault /nix/store/ygizp24vac8mm3j4dq59sajld3l4v991-cardano-addresses-8bf9890/core; + src = (pkgs.lib).mkDefault /nix/store/mppiglijmgwx201yk20kkcfdx3zp7101-cardano-addresses-b33e0f3/core; } diff --git a/nix/sha256map.nix b/nix/sha256map.nix index d8dd6e27667..365ae75735f 100644 --- a/nix/sha256map.nix +++ b/nix/sha256map.nix @@ -1,5 +1,5 @@ { - "https://github.com/input-output-hk/cardano-addresses"."8bf98905b903455196495e231b23613ad2264cb0" = "0jzlm1gnlbvz9kify2z74v9iydy6vf39nk954r73yaddknhxrq2r"; + "https://github.com/input-output-hk/cardano-addresses"."b33e0f365550bd9d329bdbb0a0d2dfe2b23a3dcf" = "05vj2fc6n8rmn3ch6115pc6l5vw6pqbv2kwbzxf3y41sa40k50vc"; "https://github.com/biocad/servant-openapi3"."4165b837d3a71debd1059c3735460075840000b5" = "1dngrr353kjhmwhn0b289jzqz5rf32llwcv79zcyq15ldpqpbib9"; "https://github.com/paolino/openapi3"."c30d0de6875d75edd64d1aac2272886528bc492d" = "0b0fzj5vrnfrc8qikabxhsnp4p8lrjpssblbh2rb7aji5hzzfli9"; "https://github.com/input-output-hk/optparse-applicative"."7497a29cb998721a9068d5725d49461f2bba0e7a" = "1gvsrg925vynwgqwplgjmp53vj953qyh3wbdf34pw21c8r47w35r"; diff --git a/stack.yaml b/stack.yaml index 773acc5e3fb..60a58fb0700 100644 --- a/stack.yaml +++ b/stack.yaml @@ -77,7 +77,7 @@ extra-deps: # cardano-addresses-3.9.0 - git: https://github.com/input-output-hk/cardano-addresses - commit: 8bf98905b903455196495e231b23613ad2264cb0 + commit: b33e0f365550bd9d329bdbb0a0d2dfe2b23a3dcf subdirs: - command-line - core From 77207d123197de04f8830f2317b9e5101320ebea Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 19 May 2022 13:00:54 +0200 Subject: [PATCH 07/10] reuse code from cardano-addresses --- .../Wallet/Primitive/AddressDiscovery/Shared.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs b/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs index 3265b6d815b..4e37468a125 100644 --- a/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs +++ b/lib/core/src/Cardano/Wallet/Primitive/AddressDiscovery/Shared.hs @@ -61,6 +61,8 @@ import Cardano.Address.Script , toScriptHash , validateScriptTemplate ) +import Cardano.Address.Script.Parser + ( scriptToText ) import Cardano.Address.Style.Shelley ( Credential (..), delegationAddress, paymentAddress ) import Cardano.Crypto.Wallet @@ -611,8 +613,8 @@ toSharedWalletId toSharedWalletId accXPub pTemplate dTemplateM = hash $ (unXPub . getRawKey $ accXPub) <> - toByteString pTemplate <> - maybe mempty toByteString dTemplateM + serializeScriptTemplate pTemplate <> + maybe mempty serializeScriptTemplate dTemplateM where - toByteString (ScriptTemplate _ script) = - T.encodeUtf8 $ T.pack $ show script + serializeScriptTemplate (ScriptTemplate _ script) = + T.encodeUtf8 $ scriptToText script From 6e4c2bee447ce183a1fb2552a5381dec2f281d19 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 19 May 2022 13:12:29 +0200 Subject: [PATCH 08/10] form a dedicated wallet id integration test --- .../Scenario/API/Shared/Wallets.hs | 31 +++++++++++++++++++ lib/core/src/Cardano/Wallet/Api/Server.hs | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs index f38bd619d4c..5bea3ce0e9a 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs @@ -136,6 +136,7 @@ spec :: forall n. , EncodeAddress n ) => SpecWith Context spec = describe "SHARED_WALLETS" $ do + it "SHARED_WALLETS_CREATE_01 - Create an active shared wallet from root xprv" $ \ctx -> runResourceT $ do m15txt <- liftIO $ genMnemonics M15 m12txt <- liftIO $ genMnemonics M12 @@ -190,6 +191,36 @@ spec = describe "SHARED_WALLETS" $ do (`shouldBe` DerivationIndex 2147483678) ] + it "SHARED_WALLETS_CREATE_01 - Compare wallet ids" $ \ctx -> runResourceT $ do + m15txt <- liftIO $ genMnemonics M15 + m12txt <- liftIO $ genMnemonics M12 + let (Right m15) = mkSomeMnemonic @'[ 15 ] m15txt + let (Right m12) = mkSomeMnemonic @'[ 12 ] m12txt + let passphrase = Passphrase $ BA.convert $ T.encodeUtf8 fixturePassphrase + let index = 30 + let accXPubDerived = accPubKeyFromMnemonics m15 (Just m12) index passphrase + let payloadPost = Json [json| { + "name": "Shared Wallet", + "mnemonic_sentence": #{m15txt}, + "mnemonic_second_factor": #{m12txt}, + "passphrase": #{fixturePassphrase}, + "account_index": "30H", + "payment_script_template": + { "cosigners": + { "cosigner#0": #{accXPubDerived} }, + "template": + { "all": + [ "cosigner#0", + { "active_from": 120 } + ] + } + } + } |] + rPost <- postSharedWallet ctx Default payloadPost + verify (fmap (view #wallet) <$> rPost) + [ expectResponseCode HTTP.status201 + ] + let wal = getFromResponse id rPost let payloadKey = Json [json|{ diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index f0ab06b364d..9b4a2a35782 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -415,8 +415,8 @@ import Cardano.Wallet.Primitive.AddressDiscovery.Shared , SharedState (..) , mkSharedStateFromAccountXPub , mkSharedStateFromRootXPrv - , validateScriptTemplates , toSharedWalletId + , validateScriptTemplates ) import Cardano.Wallet.Primitive.Delegation.UTxO ( stakeKeyCoinDistr ) From b8c09627959ba10efea279bbfaeed74725d3f127 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 19 May 2022 14:31:35 +0200 Subject: [PATCH 09/10] update cabal.project --- cabal.project | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cabal.project b/cabal.project index 12976c72994..fd7f3092045 100644 --- a/cabal.project +++ b/cabal.project @@ -60,7 +60,7 @@ source-repository-package type: git location: https://github.com/biocad/servant-openapi3 tag: 4165b837d3a71debd1059c3735460075840000b5 - + -- TODO: ADP-1713 source-repository-package type: git @@ -80,7 +80,7 @@ source-repository-package source-repository-package type: git location: https://github.com/input-output-hk/cardano-addresses - tag: 8bf98905b903455196495e231b23613ad2264cb0 + tag: b33e0f365550bd9d329bdbb0a0d2dfe2b23a3dcf subdir: command-line core From 9318550274e2c66ba216dd83eb7d3d8c78f88027 Mon Sep 17 00:00:00 2001 From: Pawel Jakubas Date: Thu, 19 May 2022 16:11:51 +0200 Subject: [PATCH 10/10] add golden test against cardano-addresses --- .../Scenario/API/Shared/Wallets.hs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs index 5bea3ce0e9a..ddaa3b2a8ed 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shared/Wallets.hs @@ -29,6 +29,7 @@ import Cardano.Wallet.Api.Types , ApiAddress , ApiFee (..) , ApiSharedWallet (..) + , ApiT (..) , ApiTransaction , ApiWallet , DecodeAddress @@ -322,6 +323,41 @@ spec = describe "SHARED_WALLETS" $ do (walAcctSameOtherScriptActive ^. #id) `shouldNotBe` (walActive ^. #id) + -- In cardano-addresses + -- $ cat phrase.prv + -- rib kiwi begin other second pool raise prosper inspire forum keep stereo option ride region + -- + -- $ cardano-address key from-recovery-phrase Shared < phrase.prv > root.shared_xsk + -- + -- $ cardano-address key child 1854H/1815H/0H < root.shared_xsk > acct.shared_xsk + -- + -- $ cardano-address key walletid --spending "all [cosigner#0]" < acct.shared_xsk + -- 654a69cd246ab08aeb4d44837ff5d5ceddfbce20 + it "SHARED_WALLETS_CREATE_01 - golden test comparing wallet id" $ \ctx -> runResourceT $ do + let payloadPost = Json [json| { + "name": "Shared Wallet", + "mnemonic_sentence": ["rib","kiwi","begin","other","second","pool","raise","prosper","inspire","forum","keep","stereo","option","ride","region"], + "passphrase": #{fixturePassphrase}, + "account_index": "0H", + "payment_script_template": + { "cosigners": + { "cosigner#0": "self" }, + "template": + { "all": ["cosigner#0"] + } + } + } |] + rPost <- postSharedWallet ctx Default payloadPost + verify (fmap (view #wallet) <$> rPost) + [ expectResponseCode HTTP.status201 + ] + + let wal = getFromResponse id rPost + let (ApiSharedWallet (Right walActive)) = wal + + toText (getApiT $ walActive ^. #id) `shouldBe` + "654a69cd246ab08aeb4d44837ff5d5ceddfbce20" + it "SHARED_WALLETS_CREATE_02 - Create a pending shared wallet from root xprv" $ \ctx -> runResourceT $ do m15txt <- liftIO $ genMnemonics M15