How to use the stellar-base.StrKey function in stellar-base

To help you get started, we’ve selected a few stellar-base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github astroband / astrograph / src / util / xdr / account.ts View on Github external
export function publicKeyFromBuffer(value: Buffer): string {
  return stellar.StrKey.encodeEd25519PublicKey(value);
}
github astroband / astrograph / src / util / xdr / signer.ts View on Github external
export function signerKeyFromXDR(xdr: any) {
  switch (xdr.switch()) {
    case stellar.xdr.SignerKeyType.signerKeyTypeEd25519():
      return stellar.StrKey.encodeEd25519PublicKey(xdr.ed25519());

    case stellar.xdr.SignerKeyType.signerKeyTypePreAuthTx():
      return stellar.StrKey.encodePreAuthTx(xdr.preAuthTx());

    case stellar.xdr.SignerKeyType.signerKeyTypeHashX():
      return stellar.StrKey.encodeSha256Hash(xdr.hashX());
  }
}
github astroband / astrograph / src / ingest / ledger_event.ts View on Github external
public static build(xdr: any): LedgerEvent | null {
    const r = LedgerEvent.getTypeAndData(xdr);
    if (r === null) {
      return null;
    }

    const accountID = LedgerEvent.getAccountID(r.data);
    if (accountID === null) {
      return null;
    }

    return new LedgerEvent(stellar.StrKey.encodeEd25519PublicKey(accountID), r.type);
  }
github astroband / astrograph / src / model / factories / signer_factory.ts View on Github external
public static fromXDR(xdr: any) {
    let key: string;
    let type: SignerType;

    switch (xdr.key().switch()) {
      case stellar.xdr.SignerKeyType.signerKeyTypeEd25519():
        key = stellar.StrKey.encodeEd25519PublicKey(xdr.key().ed25519());
        type = "ed25519";
        break;
      case stellar.xdr.SignerKeyType.signerKeyTypePreAuthTx():
        key = stellar.StrKey.encodePreAuthTx(xdr.key().preAuthTx());
        type = "preAuthTx";
        break;
      case stellar.xdr.SignerKeyType.signerKeyTypeHashX():
        key = stellar.StrKey.encodeSha256Hash(xdr.key().hashX());
        type = "hashX";
        break;
      default:
        throw new Error("We've encountered unknown XDR signer type");
    }

    return new Signer({ signer: key, weight: xdr.weight(), type });
  }