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

TypeScript stellar-sdk.StrKey类代码示例

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

本文整理汇总了TypeScript中stellar-sdk.StrKey的典型用法代码示例。如果您正苦于以下问题:TypeScript StrKey类的具体用法?TypeScript StrKey怎么用?TypeScript StrKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了StrKey类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: getAddressDetails

  /**
   * Process address into address and memo id
   *
   * @param address {String} the address
   * @returns {Object} object containing address and memo id
   */
  getAddressDetails(address) {
    const destinationDetails = url.parse(address);
    const queryDetails = querystring.parse(destinationDetails.query);
    const destinationAddress = destinationDetails.pathname;
    if (!stellar.StrKey.isValidEd25519PublicKey(destinationAddress)) {
      throw new Error(`invalid address: ${address}`);
    }
    // address doesn't have a memo id
    if (destinationDetails.pathname === address) {
      return {
        address: address,
        memoId: null
      };
    }

    if (!queryDetails.memoId) {
      // if there are more properties, the query details need to contain the memo id property
      throw new Error(`invalid address: ${address}`);
    }

    try {
      new BigNumber(queryDetails.memoId);
    } catch (e) {
      throw new Error(`invalid address: ${address}`);
    }

    if (!this.isValidMemoId(queryDetails.memoId)) {
      throw new Error(`invalid address: ${address}`);
    }

    return {
      address: destinationAddress,
      memoId: queryDetails.memoId
    };
  }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:41,代码来源:xlm.ts


示例2: normalizeAddress

 /**
  * Validate and return address with appended memo id
  *
  * @param address {String} address
  * @param memoId {String} memo id
  * @returns {String} address with memo id
  */
 normalizeAddress({ address, memoId }) {
   if (!stellar.StrKey.isValidEd25519PublicKey(address)) {
     throw new Error(`invalid address details: ${address}`);
   }
   if (this.isValidMemoId(memoId)) {
     return `${address}?memoId=${memoId}`;
   }
   return address;
 }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:16,代码来源:xlm.ts


示例3: it

  it('should generate a keypair from seed', function() {
    const seed = crypto.randomBytes(32);
    const keyPair = basecoin.generateKeyPair(seed);
    keyPair.should.have.property('pub');
    keyPair.should.have.property('prv');

    const address = keyPair.pub;
    basecoin.isValidAddress(address).should.equal(true);

    basecoin.isValidPub(keyPair.pub).should.equal(true);
    basecoin.isValidPrv(keyPair.prv).should.equal(true);

    const secret = keyPair.prv;
    stellar.StrKey.encodeEd25519SecretSeed(seed).should.equal(secret);
  });
开发者ID:BitGo,项目名称:BitGoJS,代码行数:15,代码来源:xlm.ts


示例4: co

 return co(function *() {
   // The wallet will have 3 keychains on it, usually 2 of those are generated by the platform, and 1 is generated by the user.
   // Initially, we need a root prv to generate the account, which has to be distinct from all three keychains on the wallet.
   // If a root prv is not provided, we generate a random one.
   let seed;
   const rootPrv = walletParams.rootPrivateKey;
   if (rootPrv) {
     if (!this.isValidPrv(rootPrv)) {
       throw new Error('rootPrivateKey needs to be valid ed25519 secret seed');
     }
     seed = stellar.StrKey.decodeEd25519SecretSeed(rootPrv);
   }
   const keyPair = this.generateKeyPair(seed);
   // extend the wallet initialization params
   walletParams.rootPrivateKey = keyPair.prv;
   return walletParams;
 }).call(this);
开发者ID:BitGo,项目名称:BitGoJS,代码行数:17,代码来源:xlm.ts


示例5: isValidPub

 /**
  * Return boolean indicating whether input is valid public key for the coin.
  *
  * @param {String} pub the pub to be checked
  * @returns {Boolean} is it valid?
  */
 isValidPub(pub) {
   return stellar.StrKey.isValidEd25519PublicKey(pub);
 }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:9,代码来源:xlm.ts


示例6: getPrvFromRaw

 /**
  * Get decoded ed25519 private key from raw data
  *
  * @param prv {String} Raw private key
  * @returns {String} Encoded private key
  */
 getPrvFromRaw(prv) {
   return stellar.StrKey.encodeEd25519SecretSeed(Buffer.from(prv, 'hex'));
 }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:9,代码来源:xlm.ts


示例7: getPubFromRaw

 /**
  * Get decoded ed25519 public key from raw data
  *
  * @param pub {String} Raw public key
  * @returns {String} Encoded public key
  */
 getPubFromRaw(pub) {
   return stellar.StrKey.encodeEd25519PublicKey(Buffer.from(pub, 'hex'));
 }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:9,代码来源:xlm.ts


示例8: isValidPrv

 /**
  * Return boolean indicating whether input is valid private key for the coin
  *
  * @param {String} prv the prv to be checked
  * @returns {Boolean} is it valid?
  */
 isValidPrv(prv) {
   return stellar.StrKey.isValidEd25519SecretSeed(prv);
 }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:9,代码来源:xlm.ts



注:本文中的stellar-sdk.StrKey类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript stickyReducers.stickiesReducers函数代码示例发布时间:2022-05-25
下一篇:
TypeScript stellar-sdk.StellarTomlResolver类代码示例发布时间: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