Skip to content

New operations

Latest
Compare
Choose a tag to compare
@KorzunAV KorzunAV released this 22 May 08:09
· 101 commits to master since this release

Ico.jpg

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

https://www.youtube.com/watch?v=G6Ee1h97s-s

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);