A huge update for Ditch and Cryptography.ECDSA

in utopian-io •  6 years ago 

Ico.jpg

Hello, Steemians!

A huge update for Ditch and Cryptography.ECDSA is finally ready for use!

GitHub:

https://github.com/Chainers/Ditch
https://github.com/Chainers/Cryptography.ECDSA

Release Notes:

  • Private and Public key generation (+support Steem convention)
  • AccountCreateOperation
  • AccountUpdateOperation
  • WithdrawVestingOperation
  • WitnessUpdateOperation
  • TransferToVestingOperation
  • TransferOperation

Instalation

PM> Install-Package Ditch.Steem -Version 3.1.3

PM> Install-Package Ditch.Golos -Version 3.1.3

How to use

Generate Private and Public keys

AccountCreateOperation

       var name = "userlogin";

        var op = new AccountCreateOperation
        {
            Fee = new Asset(3000, Config.SteemAssetNumSteem),
            Creator = User.Login,
            NewAccountName = User.Login,
            JsonMetadata = "",
        };

        var privateKey = Secp256K1Manager.GenerateRandomKey();
        var privateWif = "P" + Base58.EncodePrivateWif(privateKey);

        var subWif = Base58.GetSubWif(name, privateWif, "owner");
        var pk = Base58.DecodePrivateWif(subWif);
        var subPublicKey = Secp256K1Manager.GetPublicKey(pk, true);
        op.Owner.KeyAuths.Add(new KeyValuePair<PublicKeyType, ushort>(new PublicKeyType(subPublicKey), 1));

        subWif = Base58.GetSubWif(name, privateWif, "active");
        pk = Base58.DecodePrivateWif(subWif);
        subPublicKey = Secp256K1Manager.GetPublicKey(pk, true);
        op.Active.KeyAuths.Add(new KeyValuePair<PublicKeyType, ushort>(new PublicKeyType(subPublicKey), 1));

        subWif = Base58.GetSubWif(name, privateWif, "posting");
        pk = Base58.DecodePrivateWif(subWif);
        subPublicKey = Secp256K1Manager.GetPublicKey(pk, true);
        op.Posting.KeyAuths.Add(new KeyValuePair<PublicKeyType, ushort>(new PublicKeyType(subPublicKey), 1));

        subWif = Base58.GetSubWif(name, privateWif, "memo");
        pk = Base58.DecodePrivateWif(subWif);
        subPublicKey = Secp256K1Manager.GetPublicKey(pk, true);
        op.MemoKey = new PublicKeyType(subPublicKey);

        var response = Api.BroadcastOperations(User.ActiveKeys, CancellationToken.None, op);

AccountUpdateOperation

        var args = new FindAccountsArgs()
        {
            Accounts = new[] { User.Login }
        };
        var resp = Api.FindAccounts(args, CancellationToken.None);
        var acc = resp.Result.Accounts[0];

        var op = new AccountUpdateOperation(User.Login, acc.MemoKey, "new settings in json format. see acc.JsonMetadata");
        var response = Api.BroadcastOperations(User.ActiveKeys, CancellationToken.None, op);

WithdrawVestingOperation

        var op = new WithdrawVestingOperation(User.Login, new Asset(1, Config.SteemAssetNumVests));
        var response = Api.BroadcastOperations(User.ActiveKeys, CancellationToken.None, op);

WitnessUpdateOperation

        var op = new WitnessUpdateOperation(User.Login, string.Empty, new PublicKeyType("STM1111111111111111111111111111111114T1Anm"), new LegacyChainProperties(1000, new LegacyAsset(1, Config.SteemAssetNumSteem), 131072), new Asset(1, Config.SteemAssetNumSteem));
        var response = Api.BroadcastOperations(User.ActiveKeys, CancellationToken.None, op);

TransferToVestingOperation

        var op = new TransferToVestingOperation(User.Login, User.Login, new Asset(1, Config.SteemAssetNumSteem));
        var response = Api.BroadcastOperations(User.ActiveKeys, CancellationToken.None, op);

TransferOperation

        var op = new TransferOperation(User.Login, User.Login, new Asset(1, Config.SteemAssetNumSbd), "optional msg");
        var response = Api.BroadcastOperations(User.ActiveKeys, CancellationToken.None, op);

Let's blockchain! :)

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

Congratulations @korzunav.dev! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 1 year!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!