Esempio n. 1
0
        public PackedMessage PackMessage(IDid recipient, IDid sender, string message)
        {
            List <IDid> list = new List <IDid>();

            list.Add(recipient);
            return(PackMessage(list, sender, message));
        }
Esempio n. 2
0
        public void SaveTheirDidSuccesfully()
        {
            IDid did = IndyDotNet.Did.Factory.CreateTheirDid(_pool, _wallet, "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW");

            Assert.IsTrue(0 < did.Did.Length, $"Did was not set {did.Did}");
            Assert.IsTrue(0 < did.VerKey.Length, $"VerKey was not set {did.VerKey}");
        }
Esempio n. 3
0
        public BuildSchemaResult BuildSchemaRequest(IDid submitterDid, SchemaDefinition data)
        {
            string schemaJson = data.ToJson();
            string json       = LedgerAsync.BuildSchemaRequestAsync(submitterDid, schemaJson).Result;

            return(JsonConvert.DeserializeObject <BuildSchemaResult>(json));
        }
Esempio n. 4
0
        public void Initialize()
        {
            string file = PoolUtils.GenerateGenesisFile();

            _filesCreated.Add(file);

            _pool = IndyDotNet.Pool.Factory.GetPool("AllCryptoTestsPool", file);
            _pool.Create();
            _pool.Open();

            WalletConfig config = new WalletConfig()
            {
                Id = "AllCryptoTestsWalletId"
            };

            WalletCredentials credentials = new WalletCredentials()
            {
                Key = "8dvfYSt5d1taSd6yJdpjq4emkwsPDDLYxkNFysFD2cZY",
                KeyDerivationMethod = KeyDerivationMethod.RAW
            };

            _wallet = IndyDotNet.Wallet.Factory.GetWallet(config, credentials);
            _wallet.Create();
            _wallet.Open();

            IdentitySeed seed = new IdentitySeed()
            {
                Seed = "00000000000000000000000000000My1"
            };

            _senderDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed);
        }
Esempio n. 5
0
        public void CreateAndStoreDidWithNoSeedSuccessfully()
        {
            IDid did = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null);

            Assert.IsTrue(0 < did.Did.Length, $"Did was not set {did.Did}");
            Assert.IsTrue(0 < did.VerKey.Length, $"VerKey was not set {did.VerKey}");
        }
Esempio n. 6
0
        public void SignRequestNymRequestSuccessfully()
        {
            INymLedger ledger = IndyDotNet.Ledger.Factory.CreateNymLedger();

            IDid submitter = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Trustee1"
            });

            IDid target = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Trustee2"
            });

            BuildRequestResult result     = ledger.BuildRequest(submitter, target, null, null, NymRoles.NA);
            BuildRequestResult signResult = ledger.SignRequest(_wallet, submitter, result);

            Assert.IsNotNull(signResult, "failed to create SignAndSubmitRequestResult");

            // Dids are submitter: V4SGRU86Z58d6TV7PBUe6f and target: LnXR1rPnncTPZvRdmJKhJQ
            Assert.IsNotNull(signResult, "failed to create BuildNymRequestResult");
            Assert.IsTrue(0 < signResult.ReqId, "ReqId not set");
            Assert.AreEqual(signResult.Identifier, submitter.Did, $"Identifer failed match to submitter: {submitter.Did}");
            Assert.AreEqual(signResult.Operation.Dest, target.Did, $"Dest failed match to target: {target.Did}");
            Assert.IsFalse(string.IsNullOrEmpty(signResult.Signature), $"Signature not found: '{signResult.Signature}'");
        }
Esempio n. 7
0
        public BuildRequestResult BuildRequest(IDid submitterDid, IDid targetDid, string verKey, string alias, NymRoles role)
        {
            string json = LedgerAsync.BuildNymRequestAsync(submitterDid, targetDid, verKey, alias, role.AsString()).Result;

            Logger.Info($"BuildNymRequestAsync returned: {json}");

            return(JsonConvert.DeserializeObject <BuildRequestResult>(json));
        }
Esempio n. 8
0
        public BuildRequestResult BuildGetRequest(IDid submitterDid, IDid targetDid)
        {
            string json = LedgerAsync.BuildGetDdoRequestAsync(submitterDid, targetDid).Result;

            Logger.Info($"BuildGetDdoRequestAsync returned: {json}");

            return(JsonConvert.DeserializeObject <BuildRequestResult>(json));
        }
Esempio n. 9
0
        public void Demo()
        {
            // Initialization
            // 1. Creating a new local pool ledger configuration that can be used later to connect pool nodes.
            // 2. Open pool ledger and get the pool handle from libindy.
            // 3. Creates a new identity wallet
            // 4. Open identity wallet and get the wallet handle from libindy
            // SEE Initialize() above

            // 5. Generating and storing steward DID and Verkey
            IDid stewardDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Steward1"
            });

            // 6. Generating and storing Trust Anchor DID and Verkey
            IDid trustAnchor = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null);

            // 7. Build NYM request to add Trust Anchor to the ledger
            INymLedger         nymLedger  = IndyDotNet.Ledger.Factory.CreateNymLedger();
            BuildRequestResult nymRequest = nymLedger.BuildRequest(stewardDid, trustAnchor, trustAnchor.VerKey, "", NymRoles.TrustAnchor);

            // 8. Sending the nym request to ledger
            SignAndSubmitRequestResponse nymResult = nymLedger.SignAndSubmitRequest(_pool, _wallet, stewardDid, nymRequest);

            // 9. Generating new Verkey of Trust Anchor in the wallet
            trustAnchor.ReplaceStart();

            // 10. Building NYM request to update new verkey to ledger
            //     Note:  using TemnpVerKey which was set in step #9
            BuildRequestResult updateNymRequest = nymLedger.BuildRequest(trustAnchor, trustAnchor, trustAnchor.TempVerKey, "", NymRoles.TrustAnchor);

            // 11. Sending NYM request to the ledger
            SignAndSubmitRequestResponse replaceKeyResult = nymLedger.SignAndSubmitRequest(_pool, _wallet, trustAnchor, updateNymRequest);

            // 12. Applying new Trust Anchor's Verkey in wallet
            trustAnchor.ReplaceApply();

            // 13. Reading new Verkey from wallet
            trustAnchor.Refresh(true);

            // 14. Building GET_NYM request to get Trust Anchor from Verkey
            BuildRequestResult refreshNymRequest = nymLedger.BuildRequest(trustAnchor, trustAnchor, null, null, NymRoles.NA);

            // 15.Sending GET_NYM request to ledger
            SignAndSubmitRequestResponse refreshNymResult = nymLedger.SubmitRequest(_pool, refreshNymRequest);

            // 16. Comparing Trust Anchor verkeys
            Assert.AreEqual(trustAnchor.VerKey, refreshNymResult.Result.Transaction.TxnData.Dest);

            // clean up
            // Close and delete wallet
            // Close pool
            // Delete pool ledger config
            // SEE Cleanup() above
        }
Esempio n. 10
0
        public BuildRequestResult SignRequest(IWallet wallet, IDid submitterDid, BuildRequestResult buildRequest)
        {
            string nymRequestJson = buildRequest.ToJson();

            Logger.Info($"buildRequest as json: {nymRequestJson}");
            string json = SignRequest(wallet, submitterDid, nymRequestJson);

            Logger.Info($"SignRequestAsync returned: {json}");

            return(JsonConvert.DeserializeObject <BuildRequestResult>(json));
        }
Esempio n. 11
0
        public void CreateAndStoreDidWithSeedSuccessfully()
        {
            IdentitySeed seed = new IdentitySeed()
            {
                Seed = "00000000000000000000000000000My1"
            };

            IDid did = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed);

            Assert.IsTrue(0 < did.Did.Length, $"Did was not set {did.Did}");
            Assert.IsTrue(0 < did.VerKey.Length, $"VerKey was not set {did.VerKey}");
        }
Esempio n. 12
0
        public void GetMyDidAbbreviatedVerKeySuccessfully()
        {
            IdentitySeed seed = new IdentitySeed()
            {
                Seed = "00000000000000000000000000000My1",
                CID  = true
            };

            IDid   did         = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed);
            string abbreviated = did.GetAbbreviateVerkey();

            Assert.IsTrue(0 < abbreviated.Length, $"abbreviated verkey was not returned {abbreviated}");
        }
Esempio n. 13
0
        public void GetListOfDidsSuccessfully()
        {
            IdentitySeed seed = new IdentitySeed()
            {
                Seed = "00000000000000000000000000000My1"
            };

            IDid did = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed);

            List <IDid> dids = IndyDotNet.Did.Factory.GetAllMyDids(_pool, _wallet);

            Assert.IsNotNull(dids, "list was empty");
            Assert.IsTrue(0 < dids.Count, "Exptected to have more than 0 dids in list");
        }
Esempio n. 14
0
        public IssuerCredentialDefinition CreateStoreCredentialDef(IDid issuerDid, CredentialDefinitionSchema definition)
        {
            string schemaJson    = definition.ToJson();
            string tag           = definition.Tag;
            string configJson    = definition.Config.ToJson();
            string signatureType = definition.SignatureType;

            //Logger.Info($"     schemaJson = {schemaJson}");
            //Logger.Info($"     configJson = {configJson}");
            //Logger.Info($"     tag = {tag}");
            //Logger.Info($"     signatureType = {signatureType}");

            IssuerCreateAndStoreCredentialDefResult result = AnonCredsAsync.IssuerCreateAndStoreCredentialDefAsync(_wallet, issuerDid, schemaJson, tag, signatureType, configJson).Result;

            return(JsonConvert.DeserializeObject <IssuerCredentialDefinition>(result.CredDefJson));
        }
Esempio n. 15
0
        public void Demo()
        {
            // Initialization
            // 1. Creating a new local pool ledger configuration that can be used later to connect pool nodes.
            // 2. Open pool ledger and get the pool handle from libindy.
            // 3. Creates a new identity wallet
            // 4. Open identity wallet and get the wallet handle from libindy
            // SEE Initialize() above

            // PART 2
            // 5. Generating and storing steward DID and Verkey
            IDid stewardDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Steward1"
            });

            // 6. Generating and storing Trust Anchor DID and Verkey
            IDid trustAnchor = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null);

            // PART 3
            // 7. Build NYM request to add Trust Anchor to the ledger
            INymLedger         nymLedger  = IndyDotNet.Ledger.Factory.CreateNymLedger();
            BuildRequestResult nymRequest = nymLedger.BuildRequest(stewardDid, trustAnchor, trustAnchor.VerKey, "", NymRoles.TrustAnchor);

            // 8. Sending the nym request to ledger
            SignAndSubmitRequestResponse nymResult = nymLedger.SignAndSubmitRequest(_pool, _wallet, stewardDid, nymRequest);

            // PART 4
            // 9. Generating and storing DID and Verkey to query the ledger with
            IDid clientDid = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, null);

            // 10. Building the GET_NYM request to query Trust Anchor's Verkey as the Client
            IGetNymLedger      getNymLedger  = IndyDotNet.Ledger.Factory.CreateGetNymLedger();
            BuildRequestResult getNymRequest = getNymLedger.BuildGetRequest(clientDid, trustAnchor);

            // 11. Sending the GET_NYM request to the ledger
            GetNymSubmitReponse getNymSubmitRequest = getNymLedger.SubmitRequest(_pool, getNymRequest);

            // 12. Comparing Trust Anchor did as written by Steward and as retrieved in Client's query
            Assert.AreEqual(trustAnchor.Did, getNymSubmitRequest.Result.Dest, $"trustAnchor: Did = {trustAnchor.Did} VerKey = {trustAnchor.VerKey} and Result.Dest = {getNymSubmitRequest.Result.Dest}");

            // clean up
            // 13. Close and delete wallet
            // 14. Close pool
            // 15. Delete pool ledger config
            // SEE Cleanup() above
        }
Esempio n. 16
0
        public PackedMessage PackMessage(List <IDid> recipients, IDid sender, string message)
        {
            List <string> recipientsVerkey = new List <string>();

            foreach (IDid did in recipients)
            {
                recipientsVerkey.Add(did.VerKey);
            }

            string recipientsJson = recipientsVerkey.ToJson();

            byte[] messageBytes = System.Text.UTF8Encoding.UTF8.GetBytes(message);

            var byteResult = CryptoAsync.PackMessageAsync(_wallet, recipientsJson, sender.VerKey, messageBytes).Result;

            return(PackedMessage.FromBytes(byteResult));
        }
Esempio n. 17
0
        public void SetAndGetEndpointSuccessfully()
        {
            IdentitySeed seed = new IdentitySeed()
            {
                Seed = "00000000000000000000000000000My1"
            };

            IDid did = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, seed);

            IEndPoint endPoint = IndyDotNet.Did.Factory.GetEndPoint(_pool, _wallet, did);

            endPoint.Save("192.168.1.1:9000", "CnEDk9HrMnmiHXEV1WFgbVCRteYnPqsJwrTdcZaNhFVW");

            IEndPoint resultEndPoint = IndyDotNet.Did.Factory.GetEndPoint(_pool, _wallet, did);

            resultEndPoint.Open();

            Assert.AreEqual(endPoint.Address, resultEndPoint.Address);
            Assert.AreEqual(endPoint.TransportKey, resultEndPoint.TransportKey);
        }
Esempio n. 18
0
        public void BuildNymRequestAsTrustAnchorSuccessfully()
        {
            INymLedger ledger = IndyDotNet.Ledger.Factory.CreateNymLedger();

            IDid submitter = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Trustee1"
            });

            IDid target = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Trustee2"
            });

            BuildRequestResult result = ledger.BuildRequest(submitter, target, null, null, NymRoles.TrustAnchor);

            Assert.IsNotNull(result, $"failed to create BuildRequestResult");
            Assert.AreEqual(result.Identifier, submitter.Did, $"Identifer failed match to submitter: {submitter.Did}");
            Assert.AreEqual(result.Operation.Dest, target.Did, $"Dest failed match to target: {target.Did}");
        }
Esempio n. 19
0
        public void BuildDDORequestSuccessfully()
        {
            IDDOLedger ledger    = IndyDotNet.Ledger.Factory.CreateDDOLedger();
            IDid       submitter = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Trustee1"
            });

            IDid target = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Trustee2"
            });

            BuildRequestResult result = ledger.BuildGetRequest(submitter, target);

            Assert.IsNotNull(result, "failed to create BuildRequestResult");
            Assert.AreEqual(result.Operation.Type, "120", $"BuildGetDdoRequest request type did not 120: received {result.Operation.Type}");
            Assert.AreEqual(result.Identifier, submitter.Did, $"Identifer failed match to submitter: {submitter.Did}");
            Assert.AreEqual(result.Operation.Dest, target.Did, $"Dest failed match to target: {target.Did}");
        }
Esempio n. 20
0
        /// <summary>
        /// Builds Indy get request for getting fees for transactions in the ledger
        ///
        /// Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
        /// in the future releases.
        /// </summary>
        /// <returns>Indy request for getting fees for transactions in the ledger.</returns>
        /// <param name="wallet">Wallet.</param>
        /// <param name="submitterDid">DID of request sender</param>
        /// <param name="paymentMethod">Payment method.</param>
        public static Task <string> BuildGetTxnFeesRequestAsync(IWallet wallet, IDid submitterDid, string paymentMethod)
        {
            ParamGuard.NotNull(wallet, "wallet");
            ParamGuard.NotNull(submitterDid, "submitterDid");
            ParamGuard.NotNullOrWhiteSpace(paymentMethod, "paymentMethod");

            var taskCompletionSource = new TaskCompletionSource <string>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = NativeMethods.indy_build_get_txn_fees_req(
                commandHandle,
                wallet.Handle,
                submitterDid.Did,
                paymentMethod,
                BuildGetTxnFeesReqCallback);

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }
Esempio n. 21
0
        /// <summary>
        /// Builds Indy request for doing tokens minting
        /// according to this payment method.
        ///
        /// Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
        /// in the future releases.
        /// </summary>
        /// <returns>Indy request for doing tokens minting.</returns>
        /// <param name="wallet">Wallet.</param>
        /// <param name="submitterDid">Submitter did.</param>
        /// <param name="outputsJson">The list of UTXO outputs as json array:
        ///   [{
        ///     paymentAddress: &lt;str>, // payment address used as output
        ///     amount: &lt;int>, // amount of tokens to transfer to this payment address
        ///     extra: &lt;str>, // optional data
        ///   }]</param>
        /// <param name="extra">Optional information for payment operation</param>
        public static Task <PaymentResult> BuildMintRequestAsync(IWallet wallet, IDid submitterDid, string outputsJson, string extra)
        {
            ParamGuard.NotNull(wallet, "wallet");
            ParamGuard.NotNull(submitterDid, "submitterDid");
            ParamGuard.NotNullOrWhiteSpace(outputsJson, "outputsJson");

            var taskCompletionSource = new TaskCompletionSource <PaymentResult>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = NativeMethods.indy_build_mint_req(
                commandHandle,
                wallet.Handle,
                submitterDid.Did,
                outputsJson,
                extra,
                BuildMintRequestCallback);

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }
Esempio n. 22
0
        /// <summary>
        /// Modifies Indy request by adding information how to pay fees for this transaction
        /// according to selected payment method.
        ///
        /// Payment selection is performed by looking to o
        ///
        /// This method consumes set of UTXO inputs and outputs. The difference between inputs balance
        /// and outputs balance is the fee for this transaction.
        ///
        /// Not that this method also produces correct fee signatures.
        ///
        /// Format of inputs is specific for payment method. Usually it should reference payment transaction
        /// with at least one output that corresponds to payment address that user owns.
        ///
        /// Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
        /// in the future releases.
        /// </summary>
        /// <returns>The request fees async.</returns>
        /// <param name="wallet">Wallet.</param>
        /// <param name="submitterDid">DID of request sender</param>
        /// <param name="reqJson">Initial transaction request as json</param>
        /// <param name="inputsJson">The list of UTXO inputs as json array:
        ///   ["input1", ...]
        ///   Notes:
        ///     - each input should reference paymentAddress
        ///     - this param will be used to determine payment_method
        /// </param>
        /// <param name="outputsJson">outputs_json: The list of UTXO outputs as json array:
        ///   [{
        ///     paymentAddress: &lt;str>, // payment address used as output
        ///     amount: &lt;int>, // amount of tokens to transfer to this payment address
        ///     extra: &lt;str>, // optional data
        ///   }]</param>
        ///   <param name="extra">Optional information for payment operation.</param>
        public static Task <PaymentResult> AddRequestFeesAsync(IWallet wallet, IDid submitterDid, string reqJson, string inputsJson, string outputsJson, string extra)
        {
            ParamGuard.NotNull(wallet, "wallet");
            ParamGuard.NotNull(submitterDid, "submitterDid");

            var taskCompletionSource = new TaskCompletionSource <PaymentResult>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = NativeMethods.indy_add_request_fees(
                commandHandle,
                wallet.Handle,
                submitterDid.Did,
                reqJson,
                inputsJson,
                outputsJson,
                extra,
                AddRequestFeesCallback);

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }
Esempio n. 23
0
        public void SignAndSubmitRequestNymRequestSuccessfully()
        {
            INymLedger ledger = IndyDotNet.Ledger.Factory.CreateNymLedger();

            IDid submitter = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Trustee1"
            });

            IDid target = IndyDotNet.Did.Factory.CreateMyDid(_pool, _wallet, new IdentitySeed()
            {
                Seed = "000000000000000000000000Trustee2"
            });

            BuildRequestResult           result     = ledger.BuildRequest(submitter, target, null, null, NymRoles.NA);
            SignAndSubmitRequestResponse signResult = ledger.SignAndSubmitRequest(_pool, _wallet, submitter, result);

            Assert.IsNotNull(signResult, "failed to create SignAndSubmitRequestResult");

            // Dids are submitter: V4SGRU86Z58d6TV7PBUe6f and target: LnXR1rPnncTPZvRdmJKhJQ
            Assert.AreEqual(signResult.Result.Transaction.Metadata.From, submitter.Did, $"txn.metadata.from failed to match submitter: {submitter.Did}");
            Assert.AreEqual(signResult.Result.Transaction.TxnData.Dest, target.Did, $"txn.data.dest failed to match target: {target.Did}");
        }
Esempio n. 24
0
        /// <summary>
        /// Sets the endpoint details for the specified DID.
        /// </summary>
        /// <param name="wallet">The wallet containing the DID.</param>
        /// <param name="did">The DID to set the endpoint details on.</param>
        /// <param name="address">The address of the endpoint.</param>
        /// <param name="transportKey">The transport key.</param>
        /// <returns>An asynchronous <see cref="Task"/> that completes when the operation completes.</returns>
        /// <exception cref="InvalidStructureException">Thrown if the <paramref name="did"/> or <paramref name="transportKey"/> values are malformed.</exception>
        public static Task SetEndpointForDidAsync(IWallet wallet, IDid did, string address, string transportKey)
        {
            ParamGuard.NotNull(wallet, "wallet");
            ParamGuard.NotNull(did, "did");
            ParamGuard.NotNullOrWhiteSpace(did.Did, "did");
            ParamGuard.NotNullOrWhiteSpace(address, "address");
            ParamGuard.NotNullOrWhiteSpace(transportKey, "transportKey");

            var taskCompletionSource = new TaskCompletionSource <bool>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var commandResult = NativeMethods.indy_set_endpoint_for_did(
                commandHandle,
                wallet.Handle,
                did.Did,
                address,
                transportKey,
                CallbackHelper.TaskCompletingNoValueCallback
                );

            CallbackHelper.CheckResult(commandResult);

            return(taskCompletionSource.Task);
        }
Esempio n. 25
0
        /// <summary>
        /// Builds Indy request for information to verify the payment receipt
        /// </summary>
        /// <returns>Indy request for verification receipt.</returns>
        /// <param name="wallet">Wallet.</param>
        /// <param name="submitterDid">DID of request sender</param>
        /// <param name="receipt">Payment receipt to verify.</param>
        public static Task <PaymentResult> BuildVerifyPaymentRequestAsync(IWallet wallet, IDid submitterDid, string receipt)
        {
            ParamGuard.NotNull(wallet, "wallet");
            ParamGuard.NotNull(submitterDid, "submitterDid");
            ParamGuard.NotNullOrWhiteSpace(receipt, "receipt");

            var taskCompletionSource = new TaskCompletionSource <PaymentResult>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = NativeMethods.indy_build_verify_payment_req(
                commandHandle,
                wallet.Handle,
                submitterDid.Did,
                receipt,
                BuildVerifyPaymentRequestCallback);

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }
Esempio n. 26
0
        /// <summary>
        /// Builds Indy request for getting UTXO list for payment address
        /// according to this payment method.
        ///
        /// Note this endpoint is EXPERIMENTAL. Function signature and behaviour may change
        /// in the future releases.
        /// </summary>
        /// <returns>get_utxo_txn_json - Indy request for getting UTXO list for payment address
        /// payment_method</returns>
        /// <param name="wallet">Wallet.</param>
        /// <param name="submittedDid">DID of request sender</param>
        /// <param name="paymentAddress">target payment address</param>
        public static Task <PaymentResult> BuildGetPaymentSourcesAsync(IWallet wallet, IDid submittedDid, string paymentAddress)
        {
            ParamGuard.NotNull(submittedDid, "submittedDid");
            ParamGuard.NotNullOrWhiteSpace(paymentAddress, "paymentAddress");

            var taskCompletionSource = new TaskCompletionSource <PaymentResult>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var result = NativeMethods.indy_build_get_payment_sources_request(
                commandHandle,
                wallet.Handle,
                submittedDid.Did,
                paymentAddress,
                BuildGetUtxoRequestCallback);

            CallbackHelper.CheckResult(result);

            return(taskCompletionSource.Task);
        }
Esempio n. 27
0
        /// <summary>
        /// Gets the endpoint details for the specified DID.
        /// </summary>
        /// <remarks>
        /// If the <paramref name="did"/> is present in the <paramref name="wallet"/> and is considered "fresh" then
        /// the endpoint will be resolved from the wallet.  If, on the other hand, the DID is not present in the wallet or
        /// is not fresh then the details will be resolved from the <paramref name="pool"/> and will be cached in the wallet.
        /// </remarks>
        /// <param name="pool">The pool to resolve the endpoint data from if not present in the wallet.</param>
        /// <param name="wallet">The wallet containing the DID.</param>
        /// <param name="did">The DID to get the endpoint data for.</param>
        /// <returns>An asynchronous <see cref="Task{T}"/> that resolves to an <see cref="EndpointForDidResult"/> containing the endpoint information
        /// associated with the DID.</returns>
        public static Task <EndpointForDidResult> GetEndpointForDidAsync(IPool pool, IWallet wallet, IDid did)
        {
            ParamGuard.NotNull(wallet, "wallet");
            ParamGuard.NotNull(pool, "pool");
            ParamGuard.NotNull(did, "did");
            ParamGuard.NotNullOrWhiteSpace(did.Did, "did");

            var taskCompletionSource = new TaskCompletionSource <EndpointForDidResult>();
            var commandHandle        = PendingCommands.Add(taskCompletionSource);

            var commandResult = NativeMethods.indy_get_endpoint_for_did(
                commandHandle,
                wallet.Handle,
                pool.Handle,
                did.Did,
                GetEndpointForDidCompletedCallback
                );

            CallbackHelper.CheckResult(commandResult);

            return(taskCompletionSource.Task);
        }
Esempio n. 28
0
        public static IEndPoint GetEndPoint(IPool pool, IWallet wallet, IDid did)
        {
            IEndPoint endPoint = new EndpointInstance(pool, wallet, did);

            return(endPoint);
        }
Esempio n. 29
0
 protected string SignAndSubmitRequest(IPool pool, IWallet wallet, IDid submitterDid, string requestJson)
 {
     return(LedgerAsync.SignAndSubmitRequestAsync(pool, wallet, submitterDid, requestJson).Result);
 }
Esempio n. 30
0
        public SignAndSubmitRequestResponse SignAndSubmitRequest(IPool pool, IWallet wallet, IDid submitterDid, BuildRequestResult buildRequest)
        {
            string nymRequestJson = buildRequest.ToJson();

            Logger.Info($"BuildNymRequestResult as json: {nymRequestJson}");
            string json = SignAndSubmitRequest(pool, wallet, submitterDid, nymRequestJson);

            Logger.Info($"SignAndSubmitRequestAsync returned: {json}");

            return(JsonConvert.DeserializeObject <SignAndSubmitRequestResponse>(json));
        }