Ejemplo n.º 1
0
    // Send to yourself
    private IEnumerator SendNeedsWorkHandler()
    {
        if (LastWorkUI.text.Equals(""))
        {
            yield break;
        }

        // First we get the frontier
        string previous = null;
        string rep      = null;

        yield return(nanoManager.AccountInfo(address, (accountInfo) =>
        {
            previous = accountInfo.frontier;
            rep = accountInfo.representative;
        }));

        if (previous != null)
        {
            // Create the block to send
            var newBalance = currentBalance - new NanoAmount(System.Numerics.BigInteger.Parse("1000000000000000000000000"));
            var block      = nanoManager.CreateBlock(address, NanoUtils.HexStringToByteArray(privateKey), newBalance, NanoUtils.PrivateKeyToPublicKeyHexString(watcherPrivateKey), previous, rep, LastWorkUI.text);
            yield return(nanoManager.Process(block, BlockType.send, (hash) =>
            {
                if (hash != null)
                {
                    LastWorkUI.text = ""; // Clear it
                }

                Debug.Log(hash);
            }));
        }
        else
        {
            Debug.Log("Account does not exist yet");
        }
    }