デリゲートハーベスティングの有効化

あなたのアカウントのインポータンスを安全にノードと共有します

注釈

July 30, 2020: This guide is outdated and not compatible with latest 0.9.6 milestone. We will publish up-to-date instructions on how to activate delegated harvesting soon.

Use case

デリゲートハーベスティング によってノードを運用せずにブロック報酬をアカウントで得ることができます。次のガイドではアカウントの資産を毀損せずに、アカウントのインポータンスをデリゲートする方法をガイドします。

In this process, you will delegate your main account (M) importance to a proxy public key (R). Then, you will request a node to add your remote account (R) as a delegated harvester with the announcer account (A).

sequenceDiagram participant Main Account participant Announcer Account participant Network participant Node Main Account ->> Network: AccountKeyLinkTransaction(remotePublicKey) activate Network Network –>> Main Account: Confirms transaction deactivate Network Announcer Account ->> Network: TransferTransaction(nodePublicKey, encryptedRemotePrivateKey) activate Network Network –>> Announcer Account: Confirms the transaction deactivate Network Network –>> Node: Sends notification opt eligible remote account Node ->> Node: Adds delegated harvester Node ->> Node: Saves remote private key on disk end

Delegated harvesting activation diagram

前提条件

Before you can activate delegated harvesting, you need to have three accounts:

  • Main account (M) with at least 10,000 harvesting mosaic units.
  • Announcer account (A) with enough symbol.xym units to announce a transaction.
  • Remote account (R) that did not send or receive any transactions.

方法 #01: SDK を使用する

  1. それらの秘密鍵を用いた メインアカウント (M)アナウンサーアカウント (A)リモートアカウント (R) を定義します。
 // replace with network type
const networkType = NetworkType.TEST_NET;
// replace with private key
const mainAccountPrivateKey = '0000000000000000000000000000000000000000000000000000000000000000';
const mainAccount = Account.createFromPrivateKey(mainAccountPrivateKey, networkType);
const remoteAccount = Account.generateNewAccount(networkType);
// replace with private key
const announcerAccountPrivateKey = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF';
const announcerAccount = Account.createFromPrivateKey(announcerAccountPrivateKey, networkType);
 // replace with network type
const networkType = symbol_sdk_1.NetworkType.TEST_NET;
// replace with private key
const mainAccountPrivateKey = '0000000000000000000000000000000000000000000000000000000000000000';
const mainAccount = symbol_sdk_1.Account.createFromPrivateKey(mainAccountPrivateKey, networkType);
const remoteAccount = symbol_sdk_1.Account.generateNewAccount(networkType);
// replace with private key
const announcerAccountPrivateKey = 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF';
const announcerAccount = symbol_sdk_1.Account.createFromPrivateKey(announcerAccountPrivateKey, networkType);
  1. それらの公開鍵を使用して M のインポータンスを R へ委譲 するための AccountKeyLinkTransaction を作成します。
 const accountLinkTransaction = AccountKeyLinkTransaction.create(
    Deadline.create(),
    remoteAccount.publicKey,
    LinkAction.Link,
    networkType,
    UInt64.fromUint(2000000));
 const accountLinkTransaction = symbol_sdk_1.AccountKeyLinkTransaction.create(symbol_sdk_1.Deadline.create(), remoteAccount.publicKey, symbol_sdk_1.LinkAction.Link, networkType, symbol_sdk_1.UInt64.fromUint(2000000));
  1. M で AccountKeyLinkTransaction に署名して、ネットワークへアナウンスします。
 // replace with node endpoint
const nodeUrl = 'http://api-01.us-east-1.096x.symboldev.network:3000';
// replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash = '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
const signedTransaction = mainAccount.sign(accountLinkTransaction, networkGenerationHash);
transactionHttp
    .announce(signedTransaction)
    .subscribe((x) => console.log(x), (err) => console.error(err));
 // replace with node endpoint
const nodeUrl = 'http://api-01.us-east-1.096x.symboldev.network:3000';
// replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash = '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const repositoryFactory = new symbol_sdk_1.RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
const signedTransaction = mainAccount.sign(accountLinkTransaction, networkGenerationHash);
transactionHttp
    .announce(signedTransaction)
    .subscribe((x) => console.log(x), (err) => console.error(err));

トランザクションが承認されたら、デリゲートハーベスティングで接続したい ノードと R の秘密鍵を共有 します。

4. Create a PersistentDelegationRequestTransaction. Add the node’s public key as the transaction recipient and share the R’s private key by creating a special encrypted message as follows:

注釈

ノードの公開鍵を http://<node-url>:3000/node/info に問い合わせて取得します。

 // replace with node publicKey (nodeUrl + '/node/info')
const nodePublicKey = '3A537D5A1AF51158C42F80A199BB58351DBF3253C4A6A1B7BD1014682FB595EA';
const nodePublicAccount = PublicAccount.createFromPublicKey(nodePublicKey, networkType);
const persistentDelegationRequestTransaction = PersistentDelegationRequestTransaction
    .createPersistentDelegationRequestTransaction(
        Deadline.create(),
        remoteAccount.privateKey,
        nodePublicAccount.publicKey,
        networkType,
        UInt64.fromUint(2000000));
 // replace with node publicKey (nodeUrl + '/node/info')
const nodePublicKey = '3A537D5A1AF51158C42F80A199BB58351DBF3253C4A6A1B7BD1014682FB595EA';
const nodePublicAccount = symbol_sdk_1.PublicAccount.createFromPublicKey(nodePublicKey, networkType);
const persistentDelegationRequestTransaction = symbol_sdk_1.PersistentDelegationRequestTransaction
    .createPersistentDelegationRequestTransaction(symbol_sdk_1.Deadline.create(), remoteAccount.privateKey, nodePublicAccount.publicKey, networkType, symbol_sdk_1.UInt64.fromUint(2000000));

特別な暗号化メッセージ により R のプロキシ秘密鍵 が安全に共有され、ノード所有者のみが読み取り可能になります。さらに、リモートアカウントはモザイクを保有していません。価値あるアセットはメインアカウントに安全に残っており、ノード所有者によってそのセキュリティを犯すことはできません。

  1. A が特別な TransferTransaction に署名して、ネットワークへアナウンスします。
 // replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash = '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const signedTransaction = announcerAccount.sign(persistentDelegationRequestTransaction, networkGenerationHash);
// replace with node endpoint
const nodeUrl = 'http://api-01.us-east-1.096x.symboldev.network:3000';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
transactionHttp
    .announce(signedTransaction)
    .subscribe((x) => console.log(x), (err) => console.error(err));
 // replace with meta.networkGenerationHash (nodeUrl + '/node/info')
const networkGenerationHash = '1DFB2FAA9E7F054168B0C5FCB84F4DEB62CC2B4D317D861F3168D161F54EA78B';
const signedTransaction = announcerAccount.sign(persistentDelegationRequestTransaction, networkGenerationHash);
// replace with node endpoint
const nodeUrl = 'http://api-01.us-east-1.096x.symboldev.network:3000';
const repositoryFactory = new symbol_sdk_1.RepositoryFactoryHttp(nodeUrl);
const transactionHttp = repositoryFactory.createTransactionRepository();
transactionHttp
    .announce(signedTransaction)
    .subscribe((x) => console.log(x), (err) => console.error(err));

注釈

M でトランザクションをアナウンスすることもできますが、インポータンスの移転に関する情報を秘密にするために、3番目のアカウントを使用することをお勧めします。

すべてが成功すると、ノードは WebSockets を通じて暗号化メッセージを受信します。ノードがデリゲートハーベスティングをする秘密鍵を復号すると、次の条件を満たす場合、ノードの所有者は デリゲートハーベスターとして R を追加 できます。

  • ノードがデリゲートハーベスティングを許可していること
  • ノードのハーベスティングスロットが有効であること
  • リモートアカウントはトランザクションを送信も受信もしていないこと

注釈

妥当な PersistentDelegationRequestTransaction のアナウンスはデリゲートハーベスターとして追加することを保証するわけではありません。現状、アカウントがデリゲートハーベスティングを正常にアクティブ化したことを確認する唯一の方法は、新しいブロックの署名者になることです。

方法 #02: CLI を使用する

  1. CLI のプロファイルとして、最低 10,000 symbol.xym を保有する メインアカウント (M) を読み込みます。
 symbol-cli profile import --private-key 0000000000000000000000000000000000000000000000000000000000000000 --network TEST_NET --url http://api-01.us-east-1.096x.symboldev.network:3000 --profile main
  1. 新しいアカウントを作成します。このアカウントは リモートアカウント (R) として使用するものです。
 symbol-cli account generate --network-type TEST_NET
  1. M のインポータンスR へ委譲する。
 symbol-cli transaction accountlink --public-key 98DB319D390F8B52E29A5FB2B4109FD709218CA505BB38D4BC54F51E1102FCDA --action Link --profile main
  1. CLI のプロファイルとして アナウンサーアカウント (A) を読み込みます。このアカウントはトランザクションをアナウンスするのに十分な symbol.xym の残高を保つ必要があります。
 symbol-cli profile import --private-key FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF --network TEST_NET --url http://api-01.us-east-1.096x.symboldev.network:3000 --profile announcer
  1. A で委任ハーベスターとして追加するノードへリクエストを送信します。<recipient-public-key>``をノードの公開鍵で、 ``<remote-private-key>R の秘密鍵 で置き換えます。

注釈

ノードの公開鍵を http://<node-url>:3000/node/info に問い合わせて取得します。

 symbol-cli transaction persistentharvestdelegation --recipient-public-key <recipientPublicKey> --remote-private-key <remotePrivateKey> --profile announcer

ノードが潜在的な委任ハーベスタの秘密鍵を復号すると、ノード所有者はあなたを委任ハーベスタとして追加します。