當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript dpos-offline.LiskWallet類代碼示例

本文整理匯總了TypeScript中dpos-offline.LiskWallet的典型用法代碼示例。如果您正苦於以下問題:TypeScript LiskWallet類的具體用法?TypeScript LiskWallet怎麽用?TypeScript LiskWallet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了LiskWallet類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

describe('functionalities.multisignature', () => {
  initializer.setup();
  initializer.autoRestoreEach();
  let wallet: LiskWallet;

  let accountsModule: IAccountsModule;
  let blocksModule: IBlocksModule;
  let blocksSubChainModule: IBlocksModuleChain;
  let txModule: ITransactionsModule;
  let multisigModule: IMultisignaturesModule;
  let systemModule: ISystemModule;
  let txPool: ITransactionPoolLogic;
  let txLogic: ITransactionLogic;

  let TxModel: typeof TransactionsModel;
  beforeEach(async () => {
    const { wallet: w } = await createRandomAccountWithFunds(1e10);
    wallet              = w;

    TxModel              = initializer.appManager.container.get(Symbols.models.transactions);
    accountsModule       = initializer.appManager.container.get(Symbols.modules.accounts);
    blocksModule         = initializer.appManager.container.get(Symbols.modules.blocks);
    blocksSubChainModule = initializer.appManager.container.get(Symbols.modules.blocksSubModules.chain);
    multisigModule       = initializer.appManager.container.get(Symbols.modules.multisignatures);
    txModule             = initializer.appManager.container.get(Symbols.modules.transactions);
    systemModule         = initializer.appManager.container.get(Symbols.modules.system);
    txLogic              = initializer.appManager.container.get(Symbols.logic.transaction);
    txPool               = initializer.appManager.container.get(Symbols.logic.transactionPool);
  });
  it('should create a multisig account', async () => {
    const { keys, tx } = await createMultiSignAccount(
      wallet,
      [createRandomWallet(), createRandomWallet(), createRandomWallet()],
      3
    );

    const dbTX = await TxModel.findById(tx.id);
    expect(dbTX).exist;
  });

  it('should not allow creating a multisig account without main account signature', async () => {
    const { wallet: w } = await createRandomAccountWithFunds(1e10);

    const keys = await createRandomAccountsWithFunds(3, 1e10);

    const multisigTx = new MultiSignatureTx({
      multisignature: {
        keysgroup: keys.map((k) => `+${k.account.publicKey}`),
        lifetime : 48,
        min      : 2,
      },
    })
      .set('senderPublicKey', w.publicKey)
      .set('fee', systemModule.getFees().fees.multisignature)
      .set('timestamp', 1)
      .set('requesterPublicKey', keys[1].account.publicKey)
      .sign(keys[1].account.privKey);

    multisigTx.senderId   = w.address;
    multisigTx.signatures = keys.map((k) => k.account.getSignatureOfTransaction(multisigTx));

    await expect(initializer.rawMineBlockWithTxs([toBufferedTransaction(multisigTx)]))
      .rejectedWith('Account or requester account is not multisignature');
  });
  it('should not allow creating multisig account without main account second signature', async () => {
    const secondWallet = createRandomWallet();
    const secondSign   = wallet
      .signTransaction(
        new CreateSignatureTx({
          signature: { publicKey: secondWallet.publicKey },
        })
          .set('fee', systemModule.getFees().fees.secondsignature)
          .set('timestamp', 1)
      );
    await initializer.rawMineBlockWithTxs([toBufferedTransaction(secondSign)]);

    const keys       = await createRandomAccountsWithFunds(3, 1e10);
    const multisigTx = wallet.signTransaction(new MultiSignatureTx({
        multisignature: {
          keysgroup: keys.map((k) => `+${k.account.publicKey}`),
          lifetime : 48,
          min      : 2,
        },
      })
        .set('fee', systemModule.getFees().fees.multisignature)
        .set('timestamp', 1)
    );

    // from main account - no secondsignature - all multisig signatures
    multisigTx.signatures = keys.map((k) => k.account.getSignatureOfTransaction(multisigTx));

    await expect(initializer.rawMineBlockWithTxs([toBufferedTransaction(multisigTx)]))
      .rejectedWith('Failed to verify second signature');

    // With second signature but old signatures that do not account the secondSignature
    multisigTx.signSignature = secondWallet.getSignatureOfTransaction(multisigTx);
    await expect(initializer.rawMineBlockWithTxs([toBufferedTransaction(multisigTx)]))
      .rejectedWith('Failed to verify multisignature');

    // updating the signatures should work
//.........這裏部分代碼省略.........
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:101,代碼來源:multisignatures.spec.ts

示例2: beforeEach

 beforeEach(() => {
   tx            = anotherMultisig.signTransaction(new SendTx()
     .set('senderPublicKey', anotherMultisig.publicKey)
     .set('recipientId', '1R')
     .set('fee', systemModule.getFees().fees.send)
     .set('amount', 100)
     .set('timestamp', 1));
   tx.signatures = [];
 });
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:9,代碼來源:multisignatures.spec.ts

示例3: CreateSignatureTx

  it('should not allow creating multisig account without main account second signature', async () => {
    const secondWallet = createRandomWallet();
    const secondSign   = wallet
      .signTransaction(
        new CreateSignatureTx({
          signature: { publicKey: secondWallet.publicKey },
        })
          .set('fee', systemModule.getFees().fees.secondsignature)
          .set('timestamp', 1)
      );
    await initializer.rawMineBlockWithTxs([toBufferedTransaction(secondSign)]);

    const keys       = await createRandomAccountsWithFunds(3, 1e10);
    const multisigTx = wallet.signTransaction(new MultiSignatureTx({
        multisignature: {
          keysgroup: keys.map((k) => `+${k.account.publicKey}`),
          lifetime : 48,
          min      : 2,
        },
      })
        .set('fee', systemModule.getFees().fees.multisignature)
        .set('timestamp', 1)
    );

    // from main account - no secondsignature - all multisig signatures
    multisigTx.signatures = keys.map((k) => k.account.getSignatureOfTransaction(multisigTx));

    await expect(initializer.rawMineBlockWithTxs([toBufferedTransaction(multisigTx)]))
      .rejectedWith('Failed to verify second signature');

    // With second signature but old signatures that do not account the secondSignature
    multisigTx.signSignature = secondWallet.getSignatureOfTransaction(multisigTx);
    await expect(initializer.rawMineBlockWithTxs([toBufferedTransaction(multisigTx)]))
      .rejectedWith('Failed to verify multisignature');

    // updating the signatures should work
    multisigTx.signatures = keys.map((k) => k.account.getSignatureOfTransaction(multisigTx));
    await expect(initializer.rawMineBlockWithTxs([toBufferedTransaction(multisigTx)]))
      .not.rejected;
  });
開發者ID:RiseVision,項目名稱:rise-node,代碼行數:40,代碼來源:multisignatures.spec.ts


注:本文中的dpos-offline.LiskWallet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。