Bitcoin Forum
May 28, 2024, 06:31:49 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: How to speed up json/rpc calls ? to bitcoin core on: August 22, 2019, 11:04:04 PM
So, I'm running bitcoind locally.

I'm finding it to be veeery slow to work with on my local machine. After doing soem googling, I see others have had the same issues...

The REST interface is faster, but there's no interface for retrieving UTXOs from a given address... which would mean querying the slow JSON RPC client to run getaddress or hitting an external API (which defeats the purpose of running bitcoind myself).


Is there a faster alternative to querying bitcoin without querying any external APIs?

I don't mind the long waittimes for broadcasts, I guess, but for address balance checking and constructing transactions from UTXOs, I need milliseconds. I tried putting up the settings in my bitcoin.conf, and the lag still continues. I put in timeouts in my app, but it's its lagging on one request... imagine thousands per second.

I reaaaaallly don't want any external API's in this. Perhaps there's a way to consume the downloaded blockchain data and construct my own database from it, tuning for more performant SQL queries?

in the meantime, I'm going to try bitcore from bitpay.
2  Bitcoin / Bitcoin Technical Support / Re: Check address balance, get unspent TX, and broadcast thru bitcoind or bitcore on: August 20, 2019, 07:43:52 PM
Code:
$ bitcoin-cli --version
Bitcoin Core RPC client version v0.18.0.0-g2472733a24a9364e4c6233ccd04166a26a68cc65

I'm using bitcoin-cli through Ubuntu Linux subsystem and running bitcoin daemon through cmd.exe on Windows (can't seem to find the windows equivalent for bitcoin-cli for windows?)

I figure it will interface with the server running through main Windows, since it's on the same ports. I have 0.18.0 of Bitcoin Core on Windows.

3  Bitcoin / Bitcoin Technical Support / Re: Check address balance, get unspent TX, and broadcast thru bitcoind or bitcore on: August 20, 2019, 07:12:31 PM
Code:
bitcoin-cli scantxoutset start  "[\"addr(mfskMRWntcPYdDgTJRJdwzdKiiHJikfvH4)\"]"


That works (only when I enter it as a text JSON array) but I'm having issues with getting the JSON RPC request to succeed"

BitcoinRPC class from here (ruby): https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)

btc = BitcoinRPC.new("http://rpcuser:rpcpassword@127.0.0.1:18332")

btc.getaddress    => "2NCixvAERq3eDt31jM7eYATGiHdTEcizQkj"     THIS WORKS

arguments =  { action: 'start', scanobjects: ["addr(mfskMRWntcPYdDgTJRJdwzdKiiHJikfvH4)"] }.to_json

btc.scantxoutset(arguments)  => BitcoinRPC::JSONRPCError: {"code"=>-8, "message"=>"Invalid command"}   Doesn't work...
4  Bitcoin / Bitcoin Technical Support / Re: Check address balance, get unspent TX, and broadcast thru bitcoind or bitcore on: August 20, 2019, 05:36:03 PM
Okay, having another issue actually.

Continually getting 500 errors when POSTing with method scantxoutset:



method: 'scantxoutset',
id: 'jsonrpc',
action: "start",
scanobjects: [
        "addr(mfskMRWntcPYdDgTJRJdwzdKiiHJikfvH4)",
        {
          "desc": "addr(mfskMRWntcPYdDgTJRJdwzdKiiHJikfvH4)",
          "range": 1000,
        }
    ]


also tried :     [
        {
          "desc": "addr(mfskMRWntcPYdDgTJRJdwzdKiiHJikfvH4)",
          "range": 1000,
        }
    ]

and simply:

['addr(mfskMRWntcPYdDgTJRJdwzdKiiHJikfvH4)']
500 Errror and gives me the same text from the link you sent.

I'll keep testing but, I'd love if someone can point out the error
5  Bitcoin / Bitcoin Technical Support / Re: Check address balance, get unspent TX, and broadcast thru bitcoind or bitcore on: August 20, 2019, 04:28:54 PM
If you want just the UTXO(s) and don't care about an address's transaction history, you can use Bitcoin Core's scantxoutset command (available since 0.17.0) to scan just the UTXO set and retrieve the UTXOs for a given address or script. The command will also return you the total value of the UTXOs that it found for the address or script.

Once you have the UTXOs, you can get the full transactions if you have the transaction index enabled.


Thanks for the reply. I got my bitcoind server running in testnet on localhost:18332.

I'm figuring it out, but what would the url structure look like for the POST request to the RPC server for scantxoutset?'


Edit: got it, read the API reference. You POST localhost:18332 with { id: 'jsonrpc', method: 'scantxoutset', ....relevant_args } and basic auth with your rpcuser and rpc password from your bitcoin.conf. For anyone who ends up here.
6  Bitcoin / Bitcoin Technical Support / Check address balance, get unspent TX, and broadcast thru bitcoind or bitcore on: August 19, 2019, 06:09:30 PM
I'm getting Cloudflare blocked by Blockcypher and chain.so's APIs.

I'm told there's no performant (milliseconds) method to retrieve address balance for an address in one's bitcoin core wallet, it'd take minutes. Is bitcore's node tools a viable option for balance retrieval, getting unspent tx's, and broadcasting?

Any any insight for similar support tools for litecoin?

bonus question: referrals to any non-cloudflare baring API's that hold BTC and/or LTC blockchain data are appreciated
7  Bitcoin / Bitcoin Technical Support / Re: BTC Testnet Raw Transaction Errors on: August 14, 2019, 06:09:03 PM
Thanks for that explanation.

While coinb.in/crypto.js (from google) has a method to do this, I've decided to use chain.so: https://chain.so/api/v2/get_tx_unspent/BTCTEST/mxXhEhGuZj3NXDaRGqcF1hNr4WrXHwkZWr

but I'll bookmark this (in case the API is down & I need to do it manually)
8  Bitcoin / Bitcoin Technical Support / Re: BTC Testnet Raw Transaction Errors on: August 14, 2019, 03:02:02 PM
sorry, in my previous post i made the mistake of hashing the wrong thing as public key (forgot to remove the push data OP code). i removed the post right away but it seems i wasn't fast enough.
your public key is indeed correct and the hash is "b4a4ee3ae0d7816333efa3c12c14e345501b0bc5" but your signature is not valid.
broadcasting it with Electrum also gives the same error on OP_CHECKSIG operation step.

in order to sign with bitcoin core, the console method i know of is to use the signrawtransactionwithkey command in your console. you should provide your transaction that needs signing:
Code:
0100000001b6bf17c58f3cd20a9b8640f7ad8acbac429e5c6a3b8229454b5b25a91417461b000000001976a914b4a4ee3ae0d7816333efa3c12c14e345501b0bc588acffffffff01002d3101000000001976a914ba9dfc0d1e1ec0369e72a657551ae5b7c9029daa88ac0000000001000000
your private key
Code:
cVP1vgAKueUBEgDhbE9zS3yMP6ut4fqAFyCjmGsbZYeNjzR6Yxs5
your previous tranasction you are spending in this format:
Code:
'[{"txid":"1b461714a9255b4b4529823b6a5c9e42accb8aadf740869b0ad23c8fc517bfb6","vout":0, "scriptPubKey":"76a914b4a4ee3ae0d7816333efa3c12c14e345501b0bc588ac"}]' 

I was able to figure it out, final question: https://api.blockcypher.com/v1/btc/test3/txs/372f6c0ce5f54d64675f79d58916d492e691507f655d0a1765ce6ed9b90ee9c6

I got the decoded tx_hex from chain.so: 0100000001b6bf17c58f3cd20a9b8640f7ad8acbac429e5c6a3b8229454b5b25a91417461b00000 0006b48304502210091e338c62140e64f8a9786f2fff4ae5dce4c9f9a20f117585f19e382628f80 7d022012ef082eb8e8dcb85b39ea4fba65c6724e24cd45457b29bac52d528b9b7668b40121022f5 d96fa55a9edc93f0a4080c992272a6e086930937018be3534289914ff37d4ffffffff0218293101 000000001976a914ba9dfc0d1e1ec0369e72a657551ae5b7c9029daa88ac7eec590000000000197 6a914b4a4ee3ae0d7816333efa3c12c14e345501b0bc588ac00000000

any programmatic way to extract the scriptPubKey for this transaction?

How can I find the scriptPubKey to use for a given transaction? So i can get the current balance and needed txout & scriptPubKey to unlock it?
9  Bitcoin / Bitcoin Technical Support / Re: BTC Testnet Raw Transaction Errors on: August 14, 2019, 04:25:18 AM
Okay, how would I go about finding this key for a given transaction id?

is there an api or tool that does this? or even a bitcoind command?

if I understand correctly, I'm supposed to give that ID + this unlock script: 76a914b4a4ee3ae0d7816333efa3c12c14e345501b0bc588ac?

how would  retrieve the unlock script from a given tx_id?

Gotta wrap my head around this
10  Bitcoin / Bitcoin Technical Support / Re: BTC Testnet Raw Transaction Errors on: August 14, 2019, 04:07:43 AM
I see, great explanation.

I tried using the coinb.in GUI again, following you guys' advice to use the last transaction ID and the proper testnet address:

0100000001b6bf17c58f3cd20a9b8640f7ad8acbac429e5c6a3b8229454b5b25a91417461b00000 0006a473044022052c612a87add0b0aa0fdc4f6a49e24c021e03e91d15fc15c523b6f7ea51f0eb3 0220660fb3de7def0be95e3b923eeacec61c1530a95b33e17c1623cb8ec653bd53240121022f5d9 6fa55a9edc93f0a4080c992272a6e086930937018be3534289914ff37d4ffffffff01002d310100 0000001976a914ba9dfc0d1e1ec0369e72a657551ae5b7c9029daa88ac00000000

doesn't work for me on blockcypher, which is what I'm trying to use to broadcast the signed hex
11  Bitcoin / Bitcoin Technical Support / Re: BTC Testnet Raw Transaction Errors on: August 14, 2019, 03:58:48 AM
Ahhh, so as a rule of thumb, should I use the last prior transaction ID of a given address, when generating new transactions?

say, even if it was once where the address was the sender?

& yeah, I'm using coinbin's js code on a node api server.  the normal address for that segwit address is mxXhEhGuZj3NXDaRGqcF1hNr4WrXHwkZWr, also with some testnet coins on it.
12  Bitcoin / Bitcoin Technical Support / Re: BTC Testnet Raw Transaction Errors on: August 14, 2019, 03:19:47 AM
Thanks for the information.

Currently, I'm genearting a random SHA256 ID for the transaction ID part of coinb.in... is that not he way to go

How would I go about "creating" the transaction?

sorry for the super noob query
13  Bitcoin / Bitcoin Technical Support / BTC Testnet Raw Transaction Errors on: August 14, 2019, 01:51:59 AM
I'll share all relevant info, since it's all worthless testnet coins:

payment_inputs=[#<OpenStruct transaction_id="7bb973e66038b376d8b5b64a891db03b85d9f4978a24186395ec2643a137668f">], payment_outputs=[#<OpenStruct amount="0.05494782", address="bc1qh2wlcrg7rmqrd8nj5et42xh9klys98d2r0p7j0">], raw_transaction="01000000018f6637a14326ec956318248a97f4d9853bb01d894ab6b5d876b33860e673b97b00000 00000ffffffff01fed7530000000000160014ba9dfc0d1e1ec0369e72a657551ae5b7c9029daa00 000000"

receiver: seg_wit_address="bc1qh2wlcrg7rmqrd8nj5et42xh9klys98d2r0p7j0", balance="0", redeem_script="ba9dfc0d1e1ec0369e72a657551ae5b7c9029daa", private_key="54cb6d244094962be43a9aab3ebbfb14d73bb5757b4ff15fe21cbb846a58202b", public_key="0299e5048b940577eec52b298c8d91381c664e4db73d84d6780ee9f239fc0de19c", wif="cQRXmeFjXGHYVpbVV1Fu2xBev8bWu3TVzE7yYUPfVNZHrRZVyLLD", address="

sender wif: cVP1vgAKueUBEgDhbE9zS3yMP6ut4fqAFyCjmGsbZYeNjzR6Yxs5

signed_hex: 01000000018f6637a14326ec956318248a97f4d9853bb01d894ab6b5d876b33860e673b97b00000 0006a47304402203f376cc09a99e4653fc42125b3795aa7dbd7a4c71d4c43c2a77003db1cc192ef 0220084016363f9aef29072a098607d679d7525b8bf51828ef47ecba1b3e3bdcfe870121022f5d9 6fa55a9edc93f0a4080c992272a6e086930937018be3534289914ff37d4ffffffff01fed7530000 000000160014ba9dfc0d1e1ec0369e72a657551ae5b7c9029daa00000000

Tried pushing on blockcypher via API & GUI with no luck. Also tried manually inputting these values into coinb.in (which is where the code for generating these ids, etc is even from). No luck there either (plus no broadcasting to BTC testnet on coinbin).


on blockcypher: Error validating transaction: Transaction 9d0225db198a6470663e3f26653e215ea7eb773db1efe42fe6f213a6baf15ec5 orphaned, missing reference 0d764dc6312ff23808d23b5b7422a6d05999fd99b7b8b7b7f7624239940da2b8.

on bitpay: An error occured: Missing inputs. Code:-25

I stocked both addresses with some testnet BTC, you can check the balances on blockcypher.


Any tips of what I'm missing here?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!