Is it possible to create wallet via API?

@zono,


The page you made is great, I would just add a note that people should change their bitcoin and counterpartyd RPC username and password if they use real (mainnet) BTC and XCP.

In that error it says: "Either, switch to jmcorgan (recommended), use Insight, or use sochain or blockr.’], ‘message’: ‘Unknown RPC command: searchrawtransactions. Either, switch to jmcorgan (recommended), use Insight, or use sochain or blockr.’}, ‘message’: ‘Server error’}"

I mentioned this at the top of this discussion, you need to install a patched version of Bitcoin Core, or use Insight or Blockr.
If you want to try Insight, see here, stop counterpartyd (CTRL+C) and add this to your counterpartyd.conf::

blockchain-service-name=insight

Then try again.

If you want you can install a patched version of Bitcoin Core with jmcorgan addrindex patch:
https://github.com/rippler/btc-jmcorgan-addrindex-v0.9.2.0-fca268c-beta/blob/master/counterpartyd-ubuntu-14.04-lts-install.md
If you do this, then - because you already have bitcoind on your system - you need to stop bitcoind, uninstall bitcoin-qt and after you install a patched version, then run it one time with “bitcoind --reindex” so that it reindexes existing blockchain (it takes 6-12 hours!). Then you can switch to jmcorgan in Counterpartyd config file:
blockchain-service-name=jmcorgan

The easiest approach to install is to use Federated Node and pick the “countepartyd server” option (#2 in wizard), then it’s all automatic (as per http://counterparty.io/docs/build-system/federated-node/). 
But Federated Node has a more complicated setup of services and components (see https://github.com/CounterpartyXCP/counterpartyd_build/blob/master/setup_federated_node.py) so you cannot apply 100% the same logic to stand-alone counterpartyd setup which you have.

@something

Hi, I added the notice about change RPC username and password on my blog.

I installed the patched version of Bitcoin Core with jmcorgan addrindex patch you mentioned. And then I finished "bitcoind --reindex".

Now, I got a another problem I couldn't solve...
 
My problem:

I want to send an asset by counterpartyd send API but I got an error which was "Could not sign transaction with pybtctool"

What I did:

1. I got Private key (Wallet Import Format) on this page. http://gobittest.appspot.com/PrivateKey because I didn't know another way.

2. I executed "counterpartyd send.." command

counterpartyd send --source "17sdLuNtD7ZpFCVZ3Doz58fwxFF6i6CKk2" --destination "1GfcF1LSQagv65VQ1n66UAn9NF1TKmepcM" --quantity 1 --asset "XZCOIN"

3. "Sign and broadcast? (y/N)". I chose "y".

4. I got "Could not sign transaction with pybtctool" error. The detail is below.

counterpartyd send --source "17sdLuNtD7ZpFCVZ3Doz58fwxFF6i6CKk2" --destination "1GfcF1LSQagv65VQ1n66UAn9NF1TKmepcM" --quantity 1 --asset "XZCOIN"
Status: Running v9.49.1 of counterpartyd.
Status: Connecting to database.
Source not in backend wallet.
Public key (hexadecimal) or Private key (Wallet Import Format): XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Sign and broadcast? (y/N) y
Traceback (most recent call last):
  File "/home/xcp/counterpartyd_build/dist/counterpartyd/counterpartyd.py", line 675, in
    args.unsigned)
  File "/home/xcp/counterpartyd_build/dist/counterpartyd/counterpartyd.py", line 125, in cli
    signed_tx_hex = bitcoin.sign_tx(unsigned_tx_hex, private_key_wif=private_key_wif)
  File "/home/xcp/counterpartyd_build/dist/counterpartyd/lib/bitcoin.py", line 585, in sign_tx
    raise exceptions.TransactionError('Could not sign transaction with pybtctool.')
lib.exceptions.TransactionError: Could not sign transaction with pybtctool.

5. I tried to debug and I found the tx_tex and unsigned_tx_hex were same.

My questions:

1. Could you tell me any possible reason or solutions?

2. I tried to find generating WIF(Wallet Import Format) key in counterpartyd libraries but I didn't find. That's why I used "http://gobittest.appspot.com/PrivateKey". Could you tell me how to convert to WIF using counterpartyd or bitcoind methods.

P.S. 

1. Thank you so much for providing the patched version of Bitcoin Core.

2. I totally agree with you. "setup_federated_node.py" is the easiest way to install. And also "setup_federated_node.py" has some measures for security like chkrootkit and rkhunter. When I start operating Federated Node on our business, I will use the script. However, for now I want to know about counterparty step by step and deeply. We are researching if counterparty will be able to adapt to our business or not.

Thaks. Have a wonderful weekend.

@something

Can I ask about Counterblockd? I want to use Counterblockd API but Counterblockd's port (4001) does not open yet.

My questions:

1. I think that I need to open port both 4000(counterpartyd) and 4001(counterblockd) so that I can use Counterblockd API with JSON RPC. Is it right?

2. I executed "sudo sv start counterblockd" in order to start counterblockd. Is it not needed? You may be said before that it was not needed.

3. After I executed "sudo sv start counterblockd", synchronizing to counterpartyd started and may be done as far as I can see counterblockd.log. The last log is below and it seems to finish synchronizing.

2014-12-21-T16:55:47+0000 Received message 140719: {u'category': u'order_matches', u'message_index': 140719, u'timestamp': 1418867969, u'block_index': 314403, u'command': u'update', u'bindings': u'{"order_match_id": "3dcc16b49d0bc01e1c16fcf59a921bb826de4b2be30fc53db4541420c93a4e3316cb6c0170d27f97815d606fa0b6f442ce78b995cba7a9264d0a7002dd695d86", "status": "completed"}'} ...

P.S.

1. ps -ef | grep block. It seems that counterblockd works properly.

$ ps -ef | grep block
root        27     2  0 Dec19 ?        00:00:00 [kblockd]
root       776   770  0 Dec19 ?        00:00:00 runsv counterblockd
root     29655   776  0 16:55 ?        00:00:00 su -s /bin/bash -c /usr/local/bin/counterblockd --data-dir=${USER_HOME}/.config/counterblockd xcp
xcp      29656 29655  0 16:55 ?        00:00:00 /bin/sh /usr/local/bin/counterblockd --data-dir=/home/xcp/.config/counterblockd
xcp      29657 29656  0 16:55 ?        00:00:00 python3 /home/xcp/counterpartyd_build/run.py counterblockd --data-dir=/home/xcp/.config/counterblockd
xcp      29658 29657  0 16:55 ?        00:00:00 /bin/sh -c /home/xcp/counterpartyd_build/env.counterblockd/bin/python /home/xcp/counterpartyd_build/dist/counterblockd/counterblockd.py --data-dir=/home/xcp/.config/counterblockd
xcp      29659 29658  0 16:55 ?        00:00:03 /home/xcp/counterpartyd_build/env.counterblockd/bin/python /home/xcp/counterpartyd_build/dist/counterblockd/counterblockd.py --data-dir=/home/xcp/.config/counterblockd
xcp      29680 29360  0 17:04 pts/4    00:00:00 tail -f counterblockd.log
xcp      29692 29274  0 17:47 pts/1    00:00:00 grep --color=auto block

2. netstat -a | grep 400   . port 4001 does not open. 

tcp        0      0 *:4000                  *:*                     LISTEN   

3. counterblockd.conf

[Default]
backend-rpc-connect=localhost
backend-rpc-port=8332
backend-rpc-user=rpc
backend-rpc-password=XXXXXXX
counterpartyd-rpc-host=localhost
counterpartyd-rpc-port=4000
counterpartyd-rpc-user=rpc
counterpartyd-rpc-password=XXXXXXX
rpc-host=0.0.0.0
socketio-host=0.0.0.0
socketio-chat-host=0.0.0.0
redis-enable-apicache=0

Hi, I could connect to counterblockd via RPC. 

Reason:

counterblockd's RPC port is 4100 by default. Not 4001.

What I did:

1. I executed this curl command below. The method was "proxy_to_counterpartyd"

curl http://127.0.0.1:4100/api/ -H 'Content-Type: application/json; charset=UTF-8' -H 'Accept: application/json, text/javascript' --data-binary '{"jsonrpc":"2.0","id":0,"method":"proxy_to_counterpartyd","params":{"method":"get_running_info"}}'

2. I got this request normally.

{"jsonrpc": "2.0", "result": {"version_minor": 49, "last_block": {"ledger_hash": "c1f15aa37b233c1504cb29fcd53770feb068811564322f12ef3d02ddde2ede91", "txlist_hash": "1c0723604aa519a24b5bf2b07ba72c878a7a0c83989a1c457655375c8c12a674", "block_index": 335373, "block_hash": "00000000000000000155e067d8236fe07f5fa955dccc501ca7f0156bcbefa883", "difficulty": "39457671307.1387", "block_time": 1419259284, "previous_block_hash": "00000000000000000fca79b0fb84799fbc7a0ed8e4b3f26d4435f77d588ee2b7"}, "version_major": 9, "db_caught_up": true, "bitcoin_block_count": 335373, "version_revision": 1, "last_message_index": 493049, "running_testnet": false, "running_testcoin": false}, "id": 0}

Thanks.

Hi Zono


You’re welcome!

1. pybtctool 

https://github.com/CounterpartyXCP/counterpartyd/issues/182

and

http://support.counterparty.io/solution/articles/5000501929-can-i-use-pybtctool-with-counterpartyd-to-sign-a-transaction-

(It copy the content here: 

“…it may not work for some particular transactions (because of a bug in pybtctool, probably), when the address isn’t in the local instance of Bitcoin Core. The transaction should be signed manually (e.g. with the pybtc CLI tool, or any other way).”)


So there’s no real solution at the moment - it has to be done “externally”.


2. WIF

If you go to https://github.com/jmcorgan/bip32utils you can see that it can output in WIF format. But I’m not sure if that’s what you’re looking for.

Are you looking for a way to create a wallet with one address and key in the WIF format?


@something

Hi, Thank you very much.

1. pybtctool 

"..when the address isn't in the local instance of Bitcoin Core."..  All right. I changed to another approach like below and I could send my asset to another address.

(1) Generate new bitcoin address on my own server.
(2) Send my asset from counterwallet.io to the generated new address.
(3) Send the asset back to the address in counterwallet.io from my address in my own conterpartyd instance. I used "counterpartyd send.." command.
 
2. WIF
 
I needed to enter the private key(WIF) when I used "counterpartyd send.." command before. That's why I asked about WIF. However, WIF seems not be necessary when the source bitcoin address in the local instance wallet.

What my main question of this discussion is creating new wallet via WEB API (creating 12 words passphase). I may be able to find it in counterwallet's source code. I think the goal is almost there.

Please let me ask you later if I cannot find the way.

Thanks.

Hello @zono


1. If it works, great, but there should be a cheaper way (no sending). 

2. Yes, if it’s a local wallet then no WIF is necessary because the wallet knows about it natively

I will ask colleagues to take a look at your post.

Thanks!