Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

account_update2 validation fails requiring optional parameters #446

Closed
drov0 opened this issue Aug 7, 2019 · 2 comments · Fixed by #448
Closed

account_update2 validation fails requiring optional parameters #446

drov0 opened this issue Aug 7, 2019 · 2 comments · Fixed by #448

Comments

@drov0
Copy link
Contributor

drov0 commented Aug 7, 2019

Hello,

With hf21, it's now possible to update your json_metadata without the active key (https://github.com/steemit/steem/releases/tag/v0.21.0) thanks to the operation account_update2

 struct account_update2_operation : public base_operation
{
   account_name_type             account;
   optional< authority >         owner;
   optional< authority >         active;
   optional< authority >         posting;
   optional< public_key_type >   memo_key;
   string                        json_metadata;
   string                        posting_json_metadata;

   extensions_type               extensions;
};

The parameters are very close to account_update but the keys are optional.

Expected behavior

I can update my account with my posting keys

Actual behavior

The validation requires a memo key, (which is optional), which makes the whole thing fail. And if the memo key is added then the operation requires the active key which defeats the purpose of account_update2

How to reproduce

var steem = require('steem');
steem.api.setOptions({url: 'https://testnet.steemitdev.com/', useAppbaseApi :  true, address_prefix : 'TST', 'chain_id' : "46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32"});
steem.config.set('address_prefix', 'TST')
steem.config.set('chain_id', '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32')


async function account_update() {
    
    const username = "howo";
    const wif = "mysupersecretpostingkey";
    
    let ops = [];


    let account = await steem.api.callAsync('condenser_api.get_accounts', [[username]]);
    account = account[0];


    ops.push(['account_update2', {
        'account': username,
        posting_key: account.posting.key_auths[0][0],
        active_key: account.active.key_auths[0][0],
        owner_key: account.owner.key_auths[0][0],
        'json_metadata': "",
        "posting_json_metadata": ""
    }]);


    let tx = {operations: ops, extensions: []};
    
    steem.broadcast.send(tx, {posting: wif}, async function (err) {
        if (!err) {
            console.log("yey")
        } else {
            console.log(":'(");
            console.log(err);
        }
    });
}

Environment information

steem: 0.7.6, node 10.6

@mvandeberg
Copy link
Contributor

I believe the problem is with this line:

memo_key: public_key,

It should read:

memo_key: optional(public_key),

@drov0
Copy link
Contributor Author

drov0 commented Aug 7, 2019

Yep, I've tested locally and that was the issue. Thanks @mvandeberg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants