New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@tokel/bitgo-komodo-cc-lib

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tokel/bitgo-komodo-cc-lib - npm Package Compare versions

Comparing version 0.1.3 to 0.1.4

60

cc/general.js

@@ -7,2 +7,5 @@ /** borrowed from https://github.com/pbca26/bitgo-utxo-lib/blob/57f1a95694bbc825d3b055bfec8e0311181b7d2e/samples/cctokenspoc.js#L479 */

const ecpair = require('../src/ecpair');
const p2cryptoconditions = require('../src/payments/p2cryptoconditions');
const TransactionBuilder = require('../src/transaction_builder');
const Transaction = require('../src/transaction');

@@ -35,3 +38,56 @@ /**

module.exports.keyToWif = keyToWif;
module.exports.getSeedPhrase = getSeedPhrase;
async function create_normaltx(_wif, _destaddress, _satoshi) {
let wif = _wif;
let destaddress = _destaddress;
let satoshi = _satoshi;
let tx = await makeNormalTx(wif, destaddress, satoshi);
return tx.toHex();
}
async function makeNormalTx(wif, destaddress, amount) {
// init lib cryptoconditions
p2cryptoconditions.cryptoconditions = await ccimp; // note we need cryptoconditions here bcz it is used in FinalizCCtx o check if a vin is normal or cc
const txbuilder = new TransactionBuilder(mynetwork);
const txfee = 10000;
let mypair = ecpair.fromWIF(wif, mynetwork);
let txwutxos = await ccutils.createTxAndAddNormalInputs(
peers,
mypair.getPublicKeyBuffer(),
amount + txfee
);
let tx = Transaction.fromBuffer(
Buffer.from(txwutxos.txhex, 'hex'),
mynetwork
);
// zcash stuff:
txbuilder.setVersion(tx.version);
if (txbuilder.tx.version >= 3) txbuilder.setVersionGroupId(tx.versionGroupId);
// parse txwutxos.previousTxns and add them as vins to the created tx
let added = ccutils.addInputsFromPreviousTxns(
txbuilder,
tx,
txwutxos.previousTxns,
mynetwork
);
if (added < amount + txfee)
throw new Error('insufficient normal inputs (' + added + ')');
txbuilder.addOutput(destaddress, amount);
let myaddress = ccutils.pubkey2NormalAddressKmd(mypair.getPublicKeyBuffer()); // pk to kmd address
txbuilder.addOutput(myaddress, added - amount - txfee); // change
if (txbuilder.tx.version >= 4) txbuilder.setExpiryHeight(tx.expiryHeight);
ccutils.finalizeCCtx(mypair, txbuilder); // sign inputs
return txbuilder.build();
}
exports.keyToWif = keyToWif;
exports.getSeedPhrase = getSeedPhrase;
exports.create_normaltx = create_normaltx;

2

package.json
{
"name": "@tokel/bitgo-komodo-cc-lib",
"version": "0.1.3",
"version": "0.1.4",
"description": "Client-side Bitcoin JavaScript library with Komodo cryptocondions support",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc