Quras マルチシグ
マルチシグとは

マルチシグネチャ(multisig)では、1つのキーから1つの署名を行うのではなく、複数のキーを使用してQurasのトランザクションを認証する必要があります。複数のキーが必要です。

  • Qurasのコインを複数の人に所持させ、責任を分担すること。
  • 単一障害点を回避することで、ウォレットのセキュリティ侵害を実質的に困難にします。
  • 1つのシードを失ってもウォレットの損失につながらないM-of-Nバックアップ。 Qurasのmultisigモード:m =フロア(n/2) + 1は、n個のキーの間で、より多くのm個のキーがトランザクションを署名した場合、トランザクションが有効と見ていることを意味します。
マルチシグアドレスの作成とプッシュ

マルチシグアドレスは公開鍵によって生成されます。マルチシグアドレスを生成した後、それをQurasブロックチェーンにプッシュするかどうかを選択することができます。

var tx = Quras.tx.Transaction.createRegisterMultiSignTx('03e969e677c8049a04d814ba72759a77fa4fa79d24e84cc145b178b0976dfeb503');
  tx = Quras.tx.Transaction.joinMultiSignWallet(tx, '03b6c601a4b4528abf2a05d9f40b81482498058c1f9da034e1f241eceb557d23eb');
  const scriptHash = Quras.tx.Transaction.getMultiSignScriptHash(tx);
  const multisigAddress = Quras.wallet.getAddressFromScriptHash(scriptHash);
  tx.sign('bb0e2a6e667dd396c77d13398e4886fed7d31c14e48fc471896a7200ba2e6358'); // Sign the transaction using private key
  const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
  rpcServer.sendRawTransaction(tx.serialize()) // Send the transaction to RPC Server.
    .then((data) => {
      console.log(data);
    })
    .catch ((error) => {
      console.log("error");
    });
マルチシグアドレスからのXQC/XQGの転送

マルチシグアドレスからのコインの転送は、通常のQurasアドレスからのコインの転送に似ています。違いは、マルチシグトランザクションは、少なくともm = floor(n/2) + 1個のキーを必要とすることです。

Quras.api.qurasDB.getBalance(Quras.CONST.QURAS_NETWORK.DEV, 'DWrtupLj3fTsx19Zp5PjVneSrsvKdDdstS') // Get the balance of from address.
  .then((data) => {
    const balance = new Quras.wallet.Balance(data)
    var scriptHash = Quras.wallet.getScriptHashFromAddress('DWiDEG5kfyQC9gt7kJT86qXL5fp2TA5B4M'); // To address.
    const outputs = [{assetId: Quras.CONST.ASSET_ID["XQC"], // The type of coins that you want to send.
      value: 100 , // Coin amount to send.
      fee: 0.5, // fee.
      scriptHash: scriptHash}] // The scripthash of "To address".
    var testTx = Quras.tx.Transaction.createContractTx(balance, outputs) // create a transaction.
    Quras.api.qurasDB.getMyMultiSignMemberPubkeys(Quras.CONST.QURAS_NETWORK.DEV, 'DWrtupLj3fTsx19Zp5PjVneSrsvKdDdstS')
      .then((data) => {
        if (data.length < 1) throw new Error("There is no members");
        testTx.createMultiSign(data, 'f6647ec531c4938ea477aa5c99f367820fdefdcff6f24c96aa83cfa2ab1b9e97');
        // Sign the transaction using private key
        testTx = new Quras.tx.Transaction(JSON.parse(JSON.stringify(testTx)));
        testTx.joinMultiSign('7ed1aef02e9259fa81081ac2850a1e3363bbae5b5c3ac84e9ed2548848620e5f');
        // Sign the transaction using private key
        testTx.joinMultiSign('3af2373286901af9aa9a76087800109d0b63fb8e96be447f1fafcf98db21fe84');
        // Sign the transaction using private key
        testTx.joinMultiSign('bb0e2a6e667dd396c77d13398e4886fed7d31c14e48fc471896a7200ba2e6358');
        // Sign the transaction using private key
        console.log(testTx.isCompletedMultiSign());
        testTx = testTx.completeMultiSignTx();
        const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
        rpcServer.sendRawTransaction(testTx.serialize()) // Send the transaction to RPC Server.
          .then((data) => {
          }).catch ((error) => {});
      }).catch((error) => {});
  }).catch((error) => {});
マルチシグアドレスからのXQG請求

マルチシグアドレスがXQCを保有している場合、通常のQurasアドレスと同様にXQGをステーキング報酬として請求することができます;

Quras.api.qurasDB.getClaimInfo(Quras.CONST.QURAS_NETWORK.DEV, 'DWrtupLj3fTsx19Zp5PjVneSrsvKdDdstS')
  .then((data) => {
    var testTx = Quras.tx.Transaction.createClaimTxWithQurasDB('DWrtupLj3fTsx19Zp5PjVneSrsvKdDdstS', data['available']);
    Quras.api.qurasDB.getMyMultiSignMemberPubkeys(Quras.CONST.QURAS_NETWORK.DEV, 'DWrtupLj3fTsx19Zp5PjVneSrsvKdDdstS')
      .then((data) => {
        if (data.length < 1) throw new Error("There is no members");
        testTx.createMultiSign(data, 'f6647ec531c4938ea477aa5c99f367820fdefdcff6f24c96aa83cfa2ab1b9e97');
        // Sign the transaction using private key
        console.log(testTx.isCompletedMultiSign());
        testTx = new Quras.tx.Transaction(JSON.parse(JSON.stringify(testTx)));
        testTx.joinMultiSign('7ed1aef02e9259fa81081ac2850a1e3363bbae5b5c3ac84e9ed2548848620e5f');
        // Sign the transaction using private key
        console.log(testTx.isCompletedMultiSign());
        testTx.joinMultiSign('3af2373286901af9aa9a76087800109d0b63fb8e96be447f1fafcf98db21fe84');
        // Sign the transaction using private key
        console.log(testTx.isCompletedMultiSign());
        testTx.joinMultiSign('bb0e2a6e667dd396c77d13398e4886fed7d31c14e48fc471896a7200ba2e6358');
        // Sign the transaction using private key
        console.log(testTx.isCompletedMultiSign());
        testTx = testTx.completeMultiSignTx();
        const rpcServer = new Quras.rpc.RPCClient(Quras.CONST.QURAS_NETWORK.MAIN);
        rpcServer.sendRawTransaction(testTx.serialize()) // Send the transaction to RPC Server.
          .then((data) => {}).catch ((error) => {});
      }).catch((error) => {});
  }).catch((error) => {});
Qurasスマートコントラクト 開発参照