Create new multi-sig account
How I can create a new account with multi-sig, and custom permissions? In examples I just see : tr.newaccount({ creator: 'inita', 'mycontract11', owner: pubkey, active: pubkey })
Instead of passing in a pubkey string pass in an authority object.
{ threshold: 0,
keys: [ { key: 'EOS6MRy..', weight: 0 } ],
accounts: [ { permission: [Object], weight: 0 } ],
waits: [ { wait_sec: 0, weight: 0 } ] }
e.g. cleos set account permission player1 active '{"threshold": 1,"keys": [{"key": "EOS8M1jvYGgV2XuPqS2nbZaW9tRZfUjT1N88BxJVeF4jVFDLfSAzQ","weight": 1}],"accounts": [{"permission":{"actor":"landowner","permission":"eosio.code"},"weight":1}]}' owner -p player1
permission:owner,active,eosio.code,...
@jcalfee, @xiangxn Thanks guys for your help. I have a few more questions:
- How I can use array "waits"?
- In accounts.permission.permission I can use any permissions('active'/'owner') in objects 'active'/'owner' and permissions can duplicate. Is that okay?
{ account_name: 'uasdf54',
privileged: false,
last_code_update: '1970-01-01T00:00:00.000',
created: '2018-05-24T17:20:46.500',
ram_quota: -1,
net_weight: -1,
cpu_weight: -1,
net_limit: { used: -1, available: -1, max: -1 },
cpu_limit: { used: -1, available: -1, max: -1 },
ram_usage: 2852,
permissions:
[ { perm_name: 'active',
parent: 'owner',
required_auth:
{ threshold: 1,
keys:
[ { key: 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV',
weight: 1 } ],
accounts:
[ { permission: { actor: 'eosio', permission: 'active' },
weight: 1 },
{ permission: { actor: 'eosio', permission: 'owner' },
weight: 1 } ],
waits: [] } },
{ perm_name: 'owner',
parent: '',
required_auth:
{ threshold: 1,
keys:
[ { key: 'EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV',
weight: 1 } ],
accounts:
[ { permission: { actor: 'eosio', permission: 'active' },
weight: 1 },
{ permission: { actor: 'eosio', permission: 'owner' },
weight: 1 } ],
waits: [] } } ],
total_resources: null,
delegated_bandwidth: null,
voter_info: null }
- How I can create custom permissions(like eosio.code)? How I can change permissions for already exist user?
I checked the c++ code, I'm not sure about waits, they will probably document it soon. It does look like a generic parameter. If I had to guess, the smart contract would be able to supply a value so that some of the authorities will only count if their wait time has passed (withdraw delay for example). So the withdraw (aka transfer) request in the smart contract might calculate the 1st withdraw request date and today's transfer date finding it is 3 days then pass that in as provided_delay.
Permissions are arbitrary. I don't think you can duplicate them though. Unlike real life, a parent "owner" can do everything its "active" child can do. You should be able to make your own hierarchy then require only the child-most role in the smart contract.
c++ snips for waits
"transaction declares authority '${auth}', "
"but does not have signatures for it under a provided delay of ${provided_delay} ms",
"wait_weight", "", {
{"wait_sec", "uint32"},
{"weight", "weight_type"}
}
struct weight_tally_visitor {
...
uint32_t operator()(const wait_weight& permission) {
if( checker.provided_delay >= fc::seconds(permission.wait_sec) ) {
total_weight += permission.weight;
}
return total_weight;
}
// Check all permissions, from highest weight to lowest, seeing if provided authorization factors satisfies them or not
weight_tally_visitor visitor(*this, cached_permissions, depth);
for( const auto& permission : permissions )
// If we've got enough weight, to satisfy the authority, return!
if( permission.visit(visitor) >= authority.threshold ) {
KeyReverter.cancel();
return true;
}
return false;
@jcalfee thank for your answer. What about last question? Can I create custom permissions when create new user( function 'newaccount')? Or I should make something like that:
eos.newaccount({
creator: 'eosio',
name: userName,
owner: pubkey,
active: pubkey
}).then(() => {
return eos.updateauth({
account: userName,
permission: 'custom-permission',
parent: 'active',
auth: pubkey
});
});
You figured it out.. you need updateauth ..
Can you send out the code for creating your multi-signed account? thank you.@Aluman