Hot answers tagged

46

Bitcoind since 0.8 maintains two databases, the block index (in $DATADIR/blocks/index) and the chainstate (in $DATADIR/chainstate). The block index maintains information for every block, and where it is stored on disk. The chain state maintains information about the resulting state of validation as a result of the currently best known chain. Inside the ...


9

Here: var bitcoin = require('bitcoinjs-lib') data = new Buffer("Melons.") var tx = new bitcoin.TransactionBuilder() tx.addInput("aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31", 0) tx.addOutput("some address", 15000) ret = bitcoin.script.compile( [ bitcoin.opcodes.OP_RETURN, data ]) tx.addOutput(ret, 0) key = bitcoin.ECPair....


4

You can make a transaction with the hash (of the document) as a comment. That would proof that the file existed at that time. It doesn't however magically proof that a document hasn't been changed. Once you get the document, you can store the hash on the blockchain, then to check if it hasn't been changed, you can retrieve the hash and check if the ...


4

OK I know I shouldn't really answer my own question but... in the absence of a response to this question, I did a bit of hunting. Github provided the answer in a file found in the bitcoin-leveldb repository. The path to a text file containing the information leveldb->doc->table_format.txt In short, there is no easily describable table like ...


4

The way you pass parameters is wrong. I use the code below, got the right answer: const Client = require('bitcoin-core'); const client = new Client({username: 'admin', password: 'password', network: 'testnet'}) const txHex = '...


4

I used the request library to manually retrieve information from the insight API. I also used the litecore-lib library to create the transaction. var Litecoin = require("litecore-lib"); var request = require("request"); //manually hit an insight api to retrieve utxos of address function getUTXOs(address) { return new Promise((resolve, reject) => { ...


3

Instead of getblockcount, you can call getblockchaininfo and read the headers field. However, while this may give you a lot more blocks than the local block count, you will still only receive a count up to the point where your node has synced headers (which can be limited by time, network, how well synced your peers are) There is no way to always get the ...


3

This happens when your dependencies get twisted up, especially when bcoin has an update where leveldown gets upgraded. You should be good with a npm rebuild leveldown to fix the dependency tree, but if that doesn't work rm -rf node_modules && npm i


2

I tried the following, and it works: const Client = require('bitcoin-core'); const client = new Client( { username: 'yourUsernameHere', password: 'yourPasswordHere', port: '8332' } ); client.getInfo().then((help) => console.log(help));


2

Either create the transaction using constructor: var transaction = new Transaction(); or pass serialized transaction to broadcast method: insight.broadcast(tx.serialize(), ......


2

I don't know of a solution that works out-of-the-box with the requirements you've set. However, you can do some of what you need using some command-line tools available on github. Pycoin has a key utility which can be used to derive bip0032 addresses given a root. Here's a quick primer on how to use it: $ git clone http://github.com/richardkiss/pycoin $ cd ...


2

So... I found out what was wrong. The problem was in this part of the code when i was adding the inputs. I was adding an index to each input based on which number of input it was. for(var a = 0; a < input_utxos.length ; a++){ tx.addInput(input_utxos[a].tx,a) sum_outputs+=parseInt(input_utxos[a].amount); } but the index i was supossed to send ...


2

I'd suggest taking a look at chainpoint.org (Full disclosure, I'm the VP Engineering at Tierion, the creators of the Chainpoint open standard). Chainpoint currently uses the Tierion HashAPI, and you can submit hashes to the API for free. We'll provide you with a proof that you can store alongside your original document. We have a Javascript library you can ...


2

You must be running testnet in another shell or some other script that has opened the chain database. Whenever you open chain database it gets locked so only one process is in charge of it. lsof -d txt | grep filename You could try this one to locate process holding FD for it.


2

I m using bitcore for stand alone rpc because it has many new indexes and new methods. See this link https://bitcore.io/guides/bitcoin


2

Here is the solution that worked for me... bictcoin.conf txindex=1 server=1 rpcuser=username rpcpassword=password port=8444 rpcport=8332 rpcbind=127.0.0.1 rpcallowip=127.0.0.1 Bitcoin Daemon must be running DOS CMD: netstat -a -n must show listening for both ports 8444 and 8332 Good luck!


2

The input you are trying to spend appears to be vout 1 in the tx. Your current code tries to spend vout 0, which has already been spent. Try changing transaction.addInput(input.sender_prev_txid, 0); to transaction.addInput(input.sender_prev_txid, 1);


2

The Bitcoin Node is part of the blockchain network. It has nothing to do with markets and trading, and has no concept of a price. As far as the node is concerned, 1 Bitcoin = 1 Bitcoin, and that's it. If you want historical market prices, you will have to either scrape them from various exchanges yourself, or use a service such as this (I have no ...


1

Try bitcoinjs-lib The following will generate a P2SH(P2WPKH) address const bitcoin = require('bitcoinjs-lib') let pubkey = Buffer.from('027a2c8c567a5bb7777580d31d1fd8d9910d4b1bb398570e3a36e81d7522cf828a', 'hex') let address = bitcoin.payments.p2sh({redeem: bitcoin.payments.p2wpkh({ pubkey })}).address console.log('address: ', address) address: ...


1

I highly recommend looking at Bcoin. It is a full node implementation used by Purse.io but also includes a rich API for interacting with the Node and wallets. All of it running in NodeJS. Documentation is sparse but getting better. http://bcoin.io/ Otherwise, bitcoinjs https://github.com/bitcoinjs/bitcoinjs-lib is a Javascript library that lets you parse, ...


1

Try using the bip32 module. Also there are a few other things you'll need to fix as well. See Use BIP39 to generate BIP32 addresses. Note, this will generate a P2PKH address, see getAddress() function. index.js: 'use strict' var bip39 = require('bip39'); var bip32 = require('bip32'); var bitcoin = require('bitcoinjs-lib'); function getAddress (node, ...


1

const bch = require('bitcoincashjs'); const privateKey = new bch.PrivateKey('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy'); const utxos = [{ 'txId' : '115e8f72f39fad874cfab0deed11a80f24f967a84079fb56ddf53ea02e308986', 'outputIndex' : 0, 'address' : '17XBj6iFEsf8kzDMGQk5ghZipxX49VXuaV', 'script' : '...


1

Does the transaction fee of bitcored or bitcoind change everyday? It will often change because it will estimate the fee for certain confirmation targets (e.g. confirm within 4 blocks). The fee estimation will update with each block, so it may change every day. It may also change more or less frequently than daily depending on the transaction situation for ...


1

Bitcoin Core does not support querying an address balance. What you can do is import the address as watch-only into your wallet (using the importaddress RPC), and completing a rescan of the blockchain. When you're finished, the wallet will treat that address as one of its own, and track payments to it, and include it in its balance. Of course, you won't be ...


1

In your example you are telling it to place the transaction id as a GET request in the URI under the tx parameter. walletnotify=curl http://My.IP.Address:PortAppUses/walletnotify.js?tx=%s All you would need to do inside of walletnotify.js is pull the tx GET, in nodejs express that would be something like: const express = require("express"); const app = ...


1

bcoin.network.get().toString() returns main which is not a valid network string, it should be one of mainnet testnet simnet or regtest.


1

First and foremost, install bitcoin-core. I recommend compiling it yourself but there are binaries available for download. You'll want to perform all the steps in this tutorial - follow all steps for the daemon. Do not do the graphical user interface steps. https://bitcoin.org/en/full-node#ubuntu-1610 Run the daemon and use bitcoin-cli to familiarize ...


1

Consider using bcoin.js which is in pure JS. It fires events when a transaction takes place. Quite simply you can do: node.on("tx", (tx) => { console.log(tx.outputs, tx.inputs) }) Note that, in bitcoin, each transaction can have multiple outputs and inputs, so these are arrays of inputs and outputs. You can obtain the total output amount by summing ...


1

API selection with other technology selection is having major dependencies on final goal. so you have to select the best suit of technology as per the business requirement.


1

Great question! I'd take a look at multi-sig construction in Bitcore, and pair this with bitcore-wallet-service. Some combination of these two items, with an agent to act as a signatory for a third key, would build a powerful escrow service in very short order.


Only top voted, non community-wiki answers of a minimum length are eligible