account_update2 validation fails requiring optional parameters
drov0 opened this issue · 2 comments
drov0 commented
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 commented
I believe the problem is with this line:
It should read:
memo_key: optional(public_key),
drov0 commented
Yep, I've tested locally and that was the issue. Thanks @mvandeberg