How to use the stellar-sdk.Transaction 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 satoshipay / solar / src / components / TransactionRequestHandler.tsx View on Github external
setClosedStellarURI(uri)
      clearURI()

      // Clear location href, since it might contain secret search params
      window.history.pushState({}, "Solar Wallet", window.location.href.replace(window.location.search, ""))
    },
    [uri]
  )

  if (!renderedURI) {
    return null
  }

  if (renderedURI.operation === StellarUriType.Transaction) {
    if (isStellarGuardTransaction(renderedURI)) {
      const transaction = new Transaction((renderedURI as TransactionStellarUri).xdr)
      return (
        <dialog open="{Boolean(uri)}">
          
        </dialog>
      )
    }
  } else if (renderedURI.operation === SolarUriType.Import) {
    const secretKey = renderedURI.getParam("secret")
    if (secretKey) {
      return (
        <dialog open="{Boolean(uri)}">
          </dialog>
github BitGo / BitGoJS / test / v2 / unit / coins / xlm.js View on Github external
it('should fail to verify the wrong signature on a tx', co(function *() {
      const keyPair = basecoin.generateKeyPair();
      const tx = new stellar.Transaction(halfSignedTransaction.halfSigned.txBase64);
      const validSignature = basecoin.verifySignature(keyPair.pub, tx.hash(), tx.signatures[0].signature());
      validSignature.should.equal(false);
    }));
github future-tense / stargazer / app / core / services / transactions.js View on Github external
function onRequest(payload) {
		const tx = new StellarSdk.Transaction(payload.txenv);
		const networkId = horizon.getNetworkId(payload.network);
		const hash = multisig.getTransactionHash(tx, networkId);
		payload.tx = tx;
		addTransaction(hash, payload);
	}
github satoshipay / solar / src / platform / web / key-store.ts View on Github external
async signTransaction(tx: Transaction, account: Account, password: string): Promise {
      let privateKey: string
      try {
        privateKey = keyStore.getPrivateKeyData(account.id, password).privateKey
      } catch (error) {
        throw WrongPasswordError()
      }

      const keypair = Keypair.fromSecret(privateKey)

      const networkPassphrase = account.testnet ? Networks.TESTNET : Networks.PUBLIC

      const signedTx = new Transaction((tx.toEnvelope().toXDR("base64") as unknown) as string, networkPassphrase)
      signedTx.sign(keypair)

      return signedTx
    }
  }
github satoshipay / solar / src / subscriptions / recent-txs.ts View on Github external
function deserializeTx(txResponse: ServerApi.TransactionRecord, testnet: boolean) {
  const networkPassphrase = testnet ? Networks.TESTNET : Networks.PUBLIC
  return Object.assign(new Transaction(txResponse.envelope_xdr, networkPassphrase), {
    created_at: txResponse.created_at
  })
}
github satoshipay / solar / electron / src / storage.ts View on Github external
expose(ipcMain, commands.signTransactionCommand, events.signTransactionEvent, function signTransaction(
  txEnvelopeXdr,
  keyID,
  networkPassphrase,
  password
) {
  const transaction = new Transaction(txEnvelopeXdr, networkPassphrase)
  let privateKey
  try {
    privateKey = keystore.getPrivateKeyData(keyID, password).privateKey
  } catch (error) {
    throw Object.assign(new Error("Wrong password."), { name: "WrongPasswordError" })
  }

  transaction.sign(Keypair.fromSecret(privateKey))

  return transaction.toEnvelope().toXDR("base64")
})
github satoshipay / solar / src / platform / cordova / key-store.ts View on Github external
async signTransaction(transaction: Transaction, account: Account, password: string) {
      const transactionEnvelope = transaction.toEnvelope().toXDR("base64")
      const event = await sendCommand(commands.keyStore.signTransactionCommand, {
        keyID: account.id,
        networkPassphrase: account.testnet ? networkPassphrases.testnet : networkPassphrases.mainnet,
        password,
        transactionEnvelope
      })
      if (event.data.error === "Wrong password") {
        throw WrongPasswordError()
      } else {
        const signedTransactionEnvelope = event.data.result
        const networkPassphrase = account.testnet ? Networks.TESTNET : Networks.PUBLIC
        return new Transaction(signedTransactionEnvelope, networkPassphrase)
      }
    },
    async removeKey(keyID: string) {
github BitGo / BitGoJS / modules / core / src / v2 / coins / xlm.ts View on Github external
if (_.isUndefined(txPrebuild)) {
      throw new Error('missing txPrebuild parameter');
    }
    if (!_.isObject(txPrebuild)) {
      throw new Error(`txPrebuild must be an object, got type ${typeof txPrebuild}`);
    }

    if (_.isUndefined(prv)) {
      throw new Error('missing prv parameter to sign transaction');
    }
    if (!_.isString(prv)) {
      throw new Error(`prv must be a string, got type ${typeof prv}`);
    }

    const keyPair = stellar.Keypair.fromSecret(prv);
    const tx = new stellar.Transaction(txPrebuild.txBase64);
    tx.sign(keyPair);

    return {
      halfSigned: {
        txBase64: Xlm.txToString(tx),
      },
    };
  }