当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript stellar-sdk.StrKey类代码示例

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