• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript dpos-offline.LiskWallet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript liskWallet.LiskWallet类代码示例发布时间:2022-05-25
下一篇:
TypeScript dotstar-node.Dotstar类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap