How to use the stellar-sdk.Keypair.fromPublicKey function in stellar-sdk

To help you get started, we’ve selected a few stellar-sdk 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 stellar / js-stellar-wallets / src / data / DataProvider.ts View on Github external
constructor(params: DataProviderParams) {
    const accountKey = isAccount(params.accountOrKey)
      ? params.accountOrKey.publicKey
      : params.accountOrKey;

    if (!accountKey) {
      throw new Error("No account key provided.");
    }

    if (!params.serverUrl) {
      throw new Error("No server url provided.");
    }

    // make sure the account key is a real account
    try {
      Keypair.fromPublicKey(accountKey);
    } catch (e) {
      throw new Error(`The provided key was not valid: ${accountKey}`);
    }

    this.callbacks = {};
    this.errorHandlers = {};
    this.serverUrl = params.serverUrl;
    this.server = new Server(this.serverUrl);
    this.accountKey = accountKey;
    this._watcherTimeouts = {};
  }
github stellarchat / desktop-client / src / main / hardwareWalletLedger.js View on Github external
async _signTe(teSignatureBaseSerialized) {
      this.assertState(HWW_STATE.READY);
      const signatureWrapper = await this.str.signTransaction(`44'/${HardwareWalletLedger.bip44}'/${this.subaccount}'`, Buffer.from(teSignatureBaseSerialized, 'base64'));

      // add signature to transaction
      const keyPair = Keypair.fromPublicKey(this.publicKey);
      const hint = keyPair.signatureHint();
      const decoratedSignature = new xdr.DecoratedSignature({hint: hint, signature: signatureWrapper.signature});

      return decoratedSignature.toXDR().toString('base64');
    }
github satoshipay / solar / src / lib / stellar.ts View on Github external
export function signatureMatchesPublicKey(signature: xdr.DecoratedSignature, publicKey: string): boolean {
  const keypair = Keypair.fromPublicKey(publicKey)

  return signature.hint().equals(keypair.signatureHint())
}
github satoshipay / solar / src / lib / transaction.ts View on Github external
return transaction.signatures.some(signature => {
    const hint = signature.hint()
    const keypair = Keypair.fromPublicKey(publicKey)

    return hint.equals(keypair.rawPublicKey().slice(-hint.byteLength))
  })
}