We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For call info for utox in testnet and mainnet I prefer call to https://api.bitcore.io/api/BTC/mainnet/address/1M3r3n8KioSbnyGVmB9iZrsbZF7VFhzZUE/?unspent=true or https://api.bitcore.io/api/BTC/testnet/address/mmV25qC6WUUBFbfvz9XoSAde9FHiJpeUh2/?unspent=true
That replace https://blockchain.info/unspent/?active=1M3r3n8KioSbnyGVmB9iZrsbZF7VFhzZUE&format=json&cors=true
You can see the doc of api of bitcore in https://github.com/bitpay/bitcore/blob/master/packages/bitcore-node/docs/api-documentation.md
The text was updated successfully, but these errors were encountered:
import bitcore from "bitcore-lib"; import axios from 'axios'; const is_mainnet = false; const btcApi = is_mainnet ? 'https://api.bitcore.io/api/BTC/mainnet': 'https://api.bitcore.io/api/BTC/testnet'; if (is_mainnet) { bitcore.Networks.defaultNetwork = bitcore.Networks.testnet; } const createWallet = () => { var privateKey = new bitcore.PrivateKey(); var address = privateKey.toAddress(); return { address: address.toString(), privateKey: privateKey.toString() }; }; /** * * @param {*} wallet * @returns array of UTOXs */ const getUTXOs = async (wallet) => { const resposeUTOXs = await axios.get(btcApi+ '/address/' +wallet + '/?unspent=true'); return resposeUTOXs.data.map(utox => ({ address: utox.address, txId: utox.mintTxid, satoshis: +utox.value, script: utox.script, outputIndex: utox.mintIndex, })); } const buildTransaction = async ({ from, to, data, value }) => { let utxos = await getUTXOs(from); return new bitcore.Transaction() .from(utxos) .to(to, value) .change(from); } const sendSignedTransaction = async (transaction, privateKey) => { const pvtKey = new bitcore.PrivateKey(privateKey); const tx = transaction.sign(pvtKey); const txHex = tx.serialize(); return await axios.post(btcApi + '/tx/send', {rawTx: txHex}) } const walletMain = 'miniiesTdDvmpLZ3uwdxpiAEYkCA3zp7Sf' const walletMainKey = 'e6989d6eee921104087ce358469ad61ec5025b35208e9573d1d794e2308b7379'; const walletSecond = 'mhRxrgcTskzRVJda6M3METXaNmB9rmsSs3'; const transaction = await buildTransaction({ from: walletMain, to: walletSecond, value: 1000 }); const result = await sendSignedTransaction(transaction, walletMainKey);
Sorry, something went wrong.
No branches or pull requests
For call info for utox in testnet and mainnet I prefer call to
https://api.bitcore.io/api/BTC/mainnet/address/1M3r3n8KioSbnyGVmB9iZrsbZF7VFhzZUE/?unspent=true
or
https://api.bitcore.io/api/BTC/testnet/address/mmV25qC6WUUBFbfvz9XoSAde9FHiJpeUh2/?unspent=true
That replace
https://blockchain.info/unspent/?active=1M3r3n8KioSbnyGVmB9iZrsbZF7VFhzZUE&format=json&cors=true
You can see the doc of api of bitcore in
https://github.com/bitpay/bitcore/blob/master/packages/bitcore-node/docs/api-documentation.md
The text was updated successfully, but these errors were encountered: