Exemple #1
0
    private async void handleWithdrawal(WithdrawResponse withdraw)
    {
        string lnURL = withdraw.Data.Invoice.Request;

        if (string.IsNullOrEmpty(lnURL))
        {
            logger.Debug("lnURL is not set in withdrawal response.");
            logger.Debug(withdraw.Data.Invoice.Request);
            return;
        }
        QRcodeText.text = "Congrats! Withdraw " + gamePlayFeeSats + " sats";

        Texture2D texs = GenerateQR(lnURL);//Generate QR code image

        //4.Set the QR code image to image Gameobject
        QRcodeImage.GetComponent <Image>().sprite = Sprite.Create(texs, new Rect(0.0f, 0.0f, texs.width, texs.height), new Vector2(0.5f, 0.5f), 100.0f);

        //5.Subscribe to a callback method with ID to be monitored
        string status = await zbdClient.SubscribeWithDrawAsync(withdraw.Data.Id);

        if ("completed".Equals(status))
        {
            //Change the image from QR to Paid
            QRcodeImage.GetComponent <Image>().sprite = Resources.Load <Sprite>("image/withdrawn");
            logger.Debug("withdraw is success");
        }
        else
        {
            //for example, if the amount paid is not full, do something.the line below just print the status.
            logger.Error("withdraw is not success:" + status);
        }
    }
Exemple #2
0
    private async void handleWithdrawal(WithdrawResponse withdraw)
    {
        string lnURL = withdraw.Data.Invoice.Request;

        if (string.IsNullOrEmpty(lnURL))
        {
            logger.Debug("lnURL is not set in withdrawal response.");
            logger.Debug(withdraw.Data.Invoice.Request);
            return;
        }

        Texture2D texs = GenerateQR(lnURL);//Generate QR code image

        //4.Set the QR code iamge to image Gameobject
        //4.取得したBOLTからQRコードを作成し、ウオレットでスキャンするために表示する。
        QRcodeLnURL.GetComponent <Image>().sprite = Sprite.Create(texs, new Rect(0.0f, 0.0f, texs.width, texs.height), new Vector2(0.5f, 0.5f), 100.0f);

        //5.Subscribe the an callback method with invoice ID to be monitored
        //5.支払がされたら実行されるコールバックを引き渡して、コールーチンで実行する
        //        StartCoroutine(btcPayClient.SubscribeInvoiceCoroutine(invoice.Id, printInvoice));
        //StartCoroutine(btcPayClient.listenInvoice(invoice.Id, printInvoice));
        string status = await zbdClient.SubscribeWithDrawAsync(withdraw.Data.Id);

        if ("completed".Equals(status))
        {
            //インボイスのステータスがcompleteであれば、全額が支払われた状態なので、支払完了のイメージに変更する
            //Change the image from QR to Paid
            QRcodeLnURL.GetComponent <Image>().sprite = Resources.Load <Sprite>("image/withdrawn");
            logger.Debug("withdraw is success");
        }
        else
        {
            //for example, if the amount paid is not full, do something.the line below just print the status.
            //全額支払いでない場合には、なにか処理をおこなう。以下は、ただ ステータスを表示して終了。
            logger.Error("withdraw is not success:" + status);
        }
    }
Exemple #3
0
        public async void SubscribeToWithdrawalAndCompleteTest()
        {
            //client setup
            ZebedeeClient zebeedeeClient = new ZebedeeClient(zebedeeUrl, apikey);

            ///////////////////////////// Create Invoice
            Withdraw request = new Withdraw();

            string testDesc = "CSHARP IT TEST for subscribe to Withdrawal";

            request.AmountInSatoshi = 10;//Default 10 satoshi
            request.InternalId      = "IntegTest-Withdrawal-Complete " + DateTime.Now.ToString();


            //Countdown Latch
            CountdownEvent cde = new CountdownEvent(1); // initial count = 1
            //Call the API and assert within the callback
            string withdrawId = null;
            string lnurl      = null;
            Task   task       = zebeedeeClient.WithDrawAsync(request, withdrawResponse =>
            {
                try
                {
                    Assert.NotNull(withdrawResponse.Data.Invoice.Request);
                    Assert.NotNull(withdrawResponse.Data.Id);
                    Assert.Equal(request.AmountInSatoshi * 1000, withdrawResponse.Data.Amount);
                    Assert.StartsWith("lnurl", withdrawResponse.Data.Invoice.Request);

                    output.WriteLine("in action lnurl:" + withdrawResponse.Data.Invoice.Request);
                    output.WriteLine("in action id:" + withdrawResponse.Data.Id);
                    output.WriteLine("in action amount:" + withdrawResponse.Data.Amount);
                    withdrawId = withdrawResponse.Data.Id;
                    lnurl      = withdrawResponse.Data.Invoice.Request;
                }
                finally
                {
                    cde.Signal();
                }
            });

            //Latch wait
            cde.Wait(5000);
            if (cde.CurrentCount != 0)
            {
                Assert.True(false, "withdraw call timeout ");
            }

            output.WriteLine("outside lnurl:" + lnurl);

            cde.Reset();


            /////////////////////////////// SUBSCCRIBE to Withdrawal
            Task <string> subscribeWithdrawTask = zebeedeeClient.SubscribeWithDrawAsync(withdrawId);
            ///////////////////////////////  1. PUT BREAK POINT on ABOVE LINE and find the string value of variable lnurl
            //////////////////////////////// 2. Go to the QR COde site
            //////////////////////////////// https://www.the-qrcode-generator.com/
            //////////////////////////////// 3. release the breakpoint to start subscribe withdraw
            //////////////////////////////// 4. Scan QR by ZEBEDEE wallet (or any LNURL supporting wallet) to withdraw

            //SUBSCRIPTION  ASSERT
            string status = await subscribeWithdrawTask;

            output.WriteLine("Status:" + status);
            Assert.Equal("completed", status);
        }