How to use @dashevo/dashcore-lib - 5 common examples

To help you get started, we’ve selected a few @dashevo/dashcore-lib 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 citrusbyte / universal-wallet / packages / webapp / src / utils / dash.js View on Github external
const generateTx = ({ utxos, fromAddress, toAddress, privateKey, amount }) => {
  const tx = Transaction();
  tx.from(utxos);
  tx.to(toAddress, toSatoshi(amount));
  tx.change(fromAddress);
  try {
    tx.sign(privateKey);
    tx.serialize();
  } catch (err) {
    throw new Error(`Could not sign & serialize transaction: ${err}`);
  }
  return tx;
};
github citrusbyte / universal-wallet / packages / webapp / src / utils / dash.js View on Github external
export const fetchFee = async ({ to, from, privateKey, amount }) => {
  const fromAddress = Address.fromString(from);
  const toAddress = Address.fromString(to);
  const utxos = await getUnspentUtxos(fromAddress);
  const tx = generateTx({
    utxos,
    fromAddress,
    toAddress,
    privateKey,
    amount,
  });
  const { inputs, outputs } = tx.toObject();
  const totalInputs = inputs.reduce((p, c) => p + c.output.satoshis, 0);
  const totalOutputs = outputs.reduce((p, c) => p + c.satoshis, 0);
  const fee = totalInputs - totalOutputs;
  return toBTC(fee);
};
github citrusbyte / universal-wallet / packages / webapp / src / utils / dash.js View on Github external
export const broadcast = async ({ to, from, privateKey, amount }) => {
  const fromAddress = Address.fromString(from);
  const toAddress = Address.fromString(to);
  const utxos = await getUnspentUtxos(fromAddress);
  const tx = generateTx({
    utxos,
    fromAddress,
    toAddress,
    privateKey,
    amount,
  });
  return await broadcastTx(tx);
};
github citrusbyte / universal-wallet / packages / webapp / src / utils / dash.js View on Github external
body: JSON.stringify({ rawtx: tx.toString() }),
      });
      const { txid } = await raw.json();
      resolve(txid);
    } catch (err) {
      reject(`Could not broadcast tx: ${err}`);
    }
  });

export const NAME = 'Dashcoin';

export const SYMBOL = 'dash';

export const URL_TX = URL + '/insight/tx/'

export const validateAddress = Address.isValid;

export const fetchFee = async ({ to, from, privateKey, amount }) => {
  const fromAddress = Address.fromString(from);
  const toAddress = Address.fromString(to);
  const utxos = await getUnspentUtxos(fromAddress);
  const tx = generateTx({
    utxos,
    fromAddress,
    toAddress,
    privateKey,
    amount,
  });
  const { inputs, outputs } = tx.toObject();
  const totalInputs = inputs.reduce((p, c) => p + c.output.satoshis, 0);
  const totalOutputs = outputs.reduce((p, c) => p + c.satoshis, 0);
  const fee = totalInputs - totalOutputs;
github citrusbyte / universal-wallet / packages / webapp / src / utils / dash.js View on Github external
export const toPublicAddress = privateKey => {
  const pk = new PrivateKey(privateKey);
  return pk.toAddress(NETWORK).toString('hex');
}

@dashevo/dashcore-lib

A pure and powerful JavaScript Dash library.

MIT
Latest version published 2 months ago

Package Health Score

79 / 100
Full package analysis