Bitcoin Forum
December 09, 2023, 12:27:03 PM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Regex for Testnet WIF [solved] on: July 12, 2021, 07:07:41 PM
I am writing a script for dealing with bitcoin hashing and it would be useful to have a function to validate Testnet WIF , both uncompressed (starting with 9) and compressed (starting with c), such as:

Code:
92Pg46rUhgTT7romnV7iGW6W1gbGdeezqdbJCzShkCsYNzyyNcc
cNJFgo1driFnPcBdBX8BrJrpxchBWXwXCvNH5SoSkdcF6JXXwHMm
#https://en.bitcoin.it/wiki/List_of_address_prefixes

I have got regexes for most of other types of addresses, including regexes for mainet WIF types but they don't seem to match if I merely add [9c] to the prefix list.. I read somewhere that prefix and ending of testnet WIFs are different from those of mainet. Below is the regex for mainet WIFs I have got and which does not work.

Code:
[59KLc][1-9A-HJ-NP-Za-km-z]{50,51}
UPDATE: THIS ACTUALLY WORKS THO

If you guys know a regex that could work with testnet WIFs, please let me know. Or point to a page of testnet WIFs I can check and try something myself (could not find anything that helped me on Google yet)..

Cheers

UPDATE:
OK, I reckon that regex is working when adding the right prefixes in the character list.
[...]
2  Other / Beginners & Help / Bitcoind using all my RAM on: April 18, 2021, 01:02:21 AM
I am setting a home server for multiple purposes.
However, bitcoind is using a lot of RAM.
I wish to limit resource usage as I would prefer more RAM
was available for other tasks..

I tried setting some configs as per the following post:
https://bitcoin.stackexchange.com/questions/50580/how-to-run-bitcoind-in-a-low-memory-environment

Is there anything else I can do or is that just bitcoind normal behaviour to consume as much RAM as the kernel will let it have?

Here are my configs:
Code:
datadir=/media/usbhd/blockchain
txindex=1
rpcuser=XXX
rpcpassword=YYY
dbcache=300
onlynet=onion
listen=0
listenonion=0
maxconnections=8
proxy=127.0.0.1:9050
discover=0

Code:
% free -h
               total        used        free      shared  buff/cache   available
Mem:           5,7Gi       4,1Gi       1,1Gi       6,0Mi       419Mi       1,3Gi
Swap:          3,9Gi       660Mi       3,3Gi

And here is htop output:
https://imgur.com/a/wXjtqPL

OBs: the node is fully sync'ed.
3  Bitcoin / Project Development / [BASH] Script to get and process transactions by hash (bitcoin-cli wrapper) on: October 01, 2020, 01:46:52 AM
Hello guys!
It has been some months my working on some bash scripts.
These scripts warp arounf bitcoin-cli rpc calls to parse block and transaction data.
Just give it the trasaction hash or block hash/height

As i wrote some wrappers for blockchain.com APIs, I wanted to get
more or less the same information. I used functions from grondilu's
bitcoin-bash-tools..

Before trying the scripts, one needs have bitcoin-cli, openssl, jq and
bash (v4 or above) installed. Also, that is a very good idea to have bitcoin-cli
set with txindex=1 (otherwise you will need supply the block hash for the
transactions and some addresses will not be coded to base58 from their hex).

The scripts are at https://github.com/mountaineerbr/scripts

There are two scripts, one for getting block information and transaction
hashes in that block, and another to get transaction information by
transaction hash. For example:

Get info of a transaction by its hash id:
Code:
$ bitcoin.tx.sh a8bb9571a0667d63eaaaa36f9de87675f0d430e13c916248ded1d13093a77561

The output:

Code:
--------
Transaction information
TxId____: a8bb9571a0667d63eaaaa36f9de87675f0d430e13c916248ded1d13093a77561
Hash____: eac5391d9f7b411c7d6cbadb59a38bfa13399c3ecb440573f5f52b8a34001be1
BlkHash_: 0000000000000000000fb6a4d6f5dc7438f91a1bc3988c4f32b4bb8284eed0ec
Time____: 1594156611 2020-07-07T21:16:51Z
BlkTime_: 1594156611 2020-07-07T21:16:51Z
LockTime: 0
Version_: 1
Vsize___: 224
Size____: 414
Weight__: 894
Confirma: 12546

Vins
  TxIndex: 44f672f301772cf3e3fc15d424818aae8ed43468deb0cc56550dd9374578b816
  Sequenc: 4294967295
  VoutNum: 1
  Addresses
  Number_: 1 Value__: 4.68295
    type: witness_v0_scripthash
    bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej


Vouts
  Number_: 0 Value__: 0.26139693
  Addresses
    type: scripthash
    3KLwdgGf5QLHEW8qjxyv7wFpPMdVCDqu55

  Number_: 1 Value__: 0.19883951
  Addresses
    type: pubkeyhash
    1Lv9hU7h86REpDakYy9kpeTfT929b9twM5

  Number_: 2 Value__: 4.22231356
  Addresses
    type: witness_v0_scripthash
    bc1qwqdg6squsna38e46795at95yu9atm8azzmyvckulcc7kytlcckxswvvzej

One can parse all transactions from a block (ex: height 400000) using my two scripts, such as:
Code:
$ bitcoin.blk.sh -ii 400000 | bitcoin.tx.sh

I have been checking some blockchair parses that try to parse binary blockchain data,
which don't output as much useful information (at least for me, a regular user)
of a transaction as my script do.

The transaction script (bitcoin.tx.sh) is slow because depending on the transaction vins and vouts
it needs query previous transactions, too. This script can take from a fraction of a second
for a simple transaction up to a few seconds to parse a transaction with various in and out vectors.

Transaction from block 400000 and 668385 took approximately 12 minutes and 18 minutes to
parse, respectively with my script (intel i7).

The script (bitcoin.blk.sh) for parsing block data can also decode transaction hex of coinbase.

Decode coinbase from block height 668385:
Code:
$ bitcoin.blk.sh -y 668385
bb/BTC.TOP/

And the bitcoin.hx.sh will help you guys encoding and decoding public and private keys
(legacy addresses only), as well as decoding hex strings that you may get from the blockchain.

The scripts contain a help page, print with -h :
https://github.com/mountaineerbr/scripts

Cheers,
4  Bitcoin / Development & Technical Discussion / bitcoin-cli - how to get coinbase address from earlier blocks [SOLVED] on: June 16, 2020, 08:58:15 PM
hello guys.

i am new to bitcoind and bitcoin-cli, so i am sorry if my questions are newbie.

i want to explore the blockchain and usually i use a my own shell script wrapper of third-party apis, such as blockchain.info and blockchair.com. however, api calls and responses are limited so i downloaded the blockchain. my bitcoind version is 0.19.

my question is, how can i get the address of coinbase transactions of earlier blocks?
for example, in this paste below, i get the hash of block 50 and then the raw transaction from the first transaction id of the block, which is coinbase.
block 500000 example:
https://pastebin.com/P6czHJHM

after this step, i can decode the raw transaction and get an array of addresses with one item, which the coinbase address, as i understand it.
The result element in the addresses array is:

      "scriptPubKey": {
        "asm": "OP_HASH160 228f554bbf766d6f9cc828de1126e3d35d15e5fe OP_EQUAL",
        "hex": "a914228f554bbf766d6f9cc828de1126e3d35d15e5fe87",
        "reqSigs": 1,
        "type": "scripthash",
        "addresses": [
          "34qkc2iac6RsyxZVfyE2S5U5WcRsbg2dpK"
        ]



now the problem is, when i try the same procedures with blocks 50 or 50000, i can "only" get the following result (for block 50):

      "scriptPubKey": {
        "asm": "041ada81ea00c11098d2f52c20d5aa9f5ba13f9b583fda66f2a478dd7d95a7ab615159d98b63df2 e6f3ecb3ef9eda138e4587e7afd31e7f434cbb6837e17feb0c5 OP_CHECKSIG",
        "hex": "41041ada81ea00c11098d2f52c20d5aa9f5ba13f9b583fda66f2a478dd7d95a7ab615159d98b63d f2e6f3ecb3ef9eda138e4587e7afd31e7f434cbb6837e17feb0c5ac",
        "type": "pubkey"
      }


i see that in older blocks, type is pubkey and in newer block it is scripthash.. i think i should sha256sum that pubKey hex somehow in order to get the coinbase address? i am a newbie but if someone just point me to the right direction, to some reference, i will be most grateful.


block 50 example:
https://pastebin.com/5eWAkqTd

block 50000 example:
https://pastebin.com/b1kBxrS4


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!