Пример #1
0
    IEnumerator PaidArcadeHandler()
    {
        // Recieve this block

        List <PendingBlock> pendingBlocks = null;
        var arcadeAddress = NanoUtils.PrivateKeyToAddress(arcadePrivateKey);

        yield return(nanoManager.PendingBlocks(arcadeAddress, (responsePendingBlocks) =>
        {
            pendingBlocks = responsePendingBlocks;
        }));

        // Just get the first one as it will have the highest amount
        if (pendingBlocks != null && pendingBlocks.Count > 0)
        {
            // Returns the one with the highest amount
            var pendingBlock = pendingBlocks[0];
            yield return(nanoManager.ReceiveWaitConf(arcadeAddress, pendingBlock, arcadePrivateKey, (error, hash) =>
            {
                if (!error)
                {
                    var qrCodePayoutAsTexture2D = NanoUtils.GenerateQRCodeTextureWithPrivateKey(10, arcadePrivateKey, 10);
                    QRCodePayoutArcadeUI.sprite = Sprite.Create(qrCodePayoutAsTexture2D, new Rect(0.0f, 0.0f, qrCodePayoutAsTexture2D.width, qrCodePayoutAsTexture2D.height), new Vector2(0.5f, 0.5f));
                    QRCodePayArcadeUI.sprite = null;

                    // Start the payout listener
                    var expirySecs = 30;
                    nanoManager.ListenForPayoutWaitConfirmation(arcadeAddress, expirySecs, (errorPayout) =>
                    {
                        if (!errorPayout)
                        {
                            PayoutArcadeUI.text = "Extracted privateKey";
                        }
                        else
                        {
                            PayoutArcadeUI.text = "PrivateKey expired";
                            Debug.Log("Did not retrieve the payout fast enough");
                        }
                        QRCodePayoutArcadeUI.sprite = null;
                    });
                }
                else
                {
                    Debug.Log("Error with ReceiveWaitConf");
                }
            }));
        }
    }