개요
- 계정에 권한 정보 추가를 통해 이후 내 계정의 권한 정보를 가지고 상대방의 계정을 통제?할 수 있습니다.
- 일반적으로 posting 키만 추가하는 것을 권장함.
- 2개 이상의 계정 정보를 추가 가능 ( A라는 계정과 B라는 계정이 C라는 계정을 동시에 포스팅 가능 / 단, 프로그래밍적으로 처리해야 됨 )
posting 권한
- A 계정에 wonsama 계정 추가 ( posting 권한 추가 )
- 이후 wonsama 계정의 posting 키를 가지고 A 의 계정으로 글을 작성할 수 있음. ( A 계정의 보팅 또한 가능해짐 )
posting + active 권한
- A 계정에 wonsama 계정 추가 ( posting, active 권한 추가 )
- 이후 wonsama 계정의 posting 키를 가지고 A 계정으로 글을 작성할 수 있음. ( A 계정의 보팅 또한 가능해짐 )
- 이후 wonsama 계정의 active 키를 가지고 A 계정의 돈을 송금 할 수 있음.
참조 ( in steemconnect )
- 스팀커넥트에서는 참고로 계정 생성 시 스팀커넥트가 소유주가 됩니다. (유저가 아니라) 그래서 posting 키를 해당 계정에 위임하더라도 안심 할 수 있는 것입니다. ( tasteem.app, steemeasy, dlive.app, busy.app )
- 또한 스팀커넥트는 posting 권한만 처리합니다.
( 물론 스팀커넥트 자체가 해킹당하면 뭐 어쩔 수 없지만 현재까진 그런적은 없으니 안심하셔도 될거에요.. )
관련 소스코드
/*
REF :
https://github.com/steemit/steem-js/issues/165
https://steemit.com/steem/@good-karma/steem-multi-authority-permissions-and-how-active-authority-works-part-2-f158813ec0ec1
https://steemit.com/piston/@xeroc/piston-how-to-use-it-for-multisignature-accounts
*/
const steem = require('steem');
const MY_ACCOUNT = 'my_account_name'; // 내 계정명
const MY_ACCOUNT_OWNER_KEY = '5xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // 내 계정의 OWNER 키
const ADD_ACCOUNT = 'add_account_name'; // 추가 하려는 계정명
steem.api.getAccounts([ MY_ACCOUNT ], function(err, response){
if (response) {
const account = response[0];
const MY_JSON_META = account.json_metadata;
const MY_MEMO_KEY = account.memo_key;
let ownerAuth = account.owner;
let activeAuth = account.active;
let postingAuth = account.posting;
// 계정 권한을 추가한다
ownerAuth.account_auths.push([ADD_ACCOUNT, ownerAuth.weight_threshold]);
activeAuth.account_auths.push([ADD_ACCOUNT, activeAuth.weight_threshold]);
postingAuth.account_auths.push([ADD_ACCOUNT, postingAuth.weight_threshold]);
/*
* - steem.broadcast.accountUpdate 는 기본적으로 ACTIVE 권한을 필요로 함. (POSTING 바꿔도 ...)
* - OWNER 권한을 변경하고자 하는 경우에는 OWNER_KEY 정보가 필요
* - 이미 추가된 권한 정보는 또 추가 할 수 없음.
* - ownerAuth, activeAuth, postingAuth 의 값을 undefined로 설정하면 그대로 유지 됨
* - ownerAuth 정보는 1시간에 1번만 변경 가능
*/
steem.broadcast.accountUpdate( MY_ACCOUNT_OWNER_KEY, MY_ACCOUNT, ownerAuth, activeAuth,
postingAuth, MY_MEMO_KEY, MY_JSON_META, function(err, result) {
console.log(err, result);
});
}
});
[그림] https://steemd.com 에서 확인한 계정 권한이 추가된 모습