Creating a Raw Transaction - Discussion

Welcome to the discussion about this section. Here you can ask questions or post feedback about this specific lecture.

3 Likes

the first command gets an errormsg, the second was OK. So a space before the 0 is mandatory ?
(I post this to make others aware so they don’t lose too much time searching for the error)

bitcoin-cli -regtest gettxout "147a16db49aeeb1d13fb7187cf286b15712f60942b63f86340e20ce746232b72", 0

bitcoin-cli -regtest gettxout "147a16db49aeeb1d13fb7187cf286b15712f60942b63f86340e20ce746232b72",0

2 Likes

Hey, Filip, could you please in videos in the future move webcam screen to the top right corner?
I’d like to see beginning of the console writing, thank you very much.

1 Like

Could very well be. Bitcoin-cli and bitcoind is full of weird bugs.

Yes, thanks for the feedback. I will do my best

@filip, I’ve done everything according to your tutorial but I’m getting a JSON error from bitcoin-cli

The strings do contain a valid JSON. Proof :

PS C:\dev\bitcoin\daemon> node
>
> s = '[{\"txid\":\"70edfb7e1fd581a9b6c66bc2c964914939c75c3cf53750cfa494d93020eafd0e\",\"vout\":0}]'
'[{"txid":"70edfb7e1fd581a9b6c66bc2c964914939c75c3cf53750cfa494d93020eafd0e","vout":0}]'
> ss = '{\"2N8xphn3BkDjmEck9UEZP1mcUYyxkZuv3es\":49}'
'{"2N8xphn3BkDjmEck9UEZP1mcUYyxkZuv3es":49}'
> j = JSON.parse(s)
[ { txid: '70edfb7e1fd581a9b6c66bc2c964914939c75c3cf53750cfa494d93020eafd0e',
    vout: 0 } ]
> jj = JSON.parse(ss)
{ '2N8xphn3BkDjmEck9UEZP1mcUYyxkZuv3es': 49 }
>

It’s in windows 10 home under linux subsystem (ubuntu) .

P.S. No luck running bitcoind natively.

PS C:\WINDOWS\system32> cd C:\dev\bitcoin\daemon\
PS C:\dev\bitcoin\daemon> .\bitcoind.exe -regtest
2019-04-29T16:52:36Z Bitcoin Core version v0.17.1 (release build)
2019-04-29T16:52:36Z InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2019-04-29T16:52:36Z Validating signatures for all blocks.
2019-04-29T16:52:36Z Setting nMinimumChainWork=0000000000000000000000000000000000000000000000000000000000000000
2019-04-29T16:52:36Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2019-04-29T16:52:36Z Using RdRand as an additional entropy source
2019-04-29T16:52:37Z Default data directory C:\Users\dino\AppData\Roaming\Bitcoin
2019-04-29T16:52:37Z Using data directory C:\Users\dino\AppData\Roaming\Bitcoin\regtest
2019-04-29T16:52:37Z Using config file C:\Users\dino\AppData\Roaming\Bitcoin\bitcoin.conf
2019-04-29T16:52:37Z Using at most 125 automatic connections (2048 file descriptors available)
2019-04-29T16:52:37Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2019-04-29T16:52:37Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2019-04-29T16:52:37Z Using 4 threads for script verification
2019-04-29T16:52:37Z scheduler thread start
2019-04-29T16:52:37Z libevent: getaddrinfo: nodename nor servname provided, or not known
2019-04-29T16:52:37Z Binding RPC on address ::1 port 18443 failed.
2019-04-29T16:52:37Z Binding RPC on address 127.0.0.1 port 18443 failed.
2019-04-29T16:52:37Z Unable to bind any endpoint for RPC server
2019-04-29T16:52:37Z Error: Unable to start HTTP server. See debug log for details.
Error: Unable to start HTTP server. See debug log for details.
2019-04-29T16:52:37Z Shutdown: In progress...
2019-04-29T16:52:37Z scheduler thread interrupt
2019-04-29T16:52:37Z Shutdown: done
PS C:\dev\bitcoin\daemon> .\bitcoind.exe -regtest -daemon
Error: -daemon is not supported on this operating system
PS C:\dev\bitcoin\daemon>

First of all, like I said in the video. Bitcoin-cli and bitcoind are full of bugs and weird behaviour. I will try to help you the best I can.

I’m using windows, so my JSON parsing could be different. When I tried it on my mac I needed to format it differently. You can try this string instead, that worked for me on my mac. Obvously replace TXID and VOUT and address.

'''
    [
      {
        "txid": "'$UTXO_TXID'",
        "vout": '$UTXO_VOUT'
      }
    ]
    ''' '''
    {
      "'$NEW_ADDRESS'": 49.9999
    }'''

In regards to bitcoind. It can’t bind to any of your ports. Do you have ports used or blocked? Perhaps try outside of your subsystem. It tried to bind to 18443 and can’t do it.

1 Like

Just default windows settings. Nothing really special.
I’m usually working under a non-priviliged user. Run As Administrator for powershell has not helped though. I’ll try to look at the firewall/security settings of windows later. I’ll let you know if I figure out the root cause.

So far I’m planning to make the commands work under “windows ==> ubuntu subsystem”.

Bitcoin-cli and bitcoind are full of bugs and weird behaviour.

Yeah, I remember.
Just hoped you encountered similar issues while preparing your video (and you would share “how to resolve them quickly”). No luck but it’s ok. I’ll figure it out.

I will try to help you the best I can.

Thanks. I appreciate.

@filip, string escaping is not needed under linux.
Just letting you know.

4 Likes

Great! I’m glad you solved it. I’m not sure how subsystems handle ports. You might have to do some research as to why it can’t bind. Might be a lot of resources in the bitcoin forums as well.

I assume you don’t have another bitcoin instance running on that port? Even in the background. If so you need to stop it. You could also try to changing the port in your bitcoin.conf.

No. I don’t think so.

You might have to do some research as to why it can’t bind. Might be a lot of resources in the bitcoin forums as well.
You could also try to changing the port in your bitcoin.conf.

I’ll try this later. Thanks.

So I’ve managed to sign and send the raw transaction (in Linux subsystem of Win10). as Philip has shown in his video.

dodikk@DESKTOP-MJQ2MP4:~$ bitcoin-cli -regtest sendrawtransaction 02000000010efdea2030d994a4cf5037f53c5cc739499164c9c26bc6b6a981d51f7efbed70000000004847304402200438ece7a4304ea3115bb51e714e2e99f5f3506e9f8240d493ed41f4555aacf802203b1320202791e8ca9f5fda6e0996d6defeb1a19fab3f5e9fdc8e57aeb0b84d6801ffffffff02001110240100000017a914ac67eb8ee455667ce1ccd6bcaf115d0b29f8509687c09ee6050000000017a914994748a8b84b091227c3b68773df3921004e61a18700000000

bca213de3e96254cf0840566ab375c2b1d6640d7bcf045d738c2a444e33f3e26


dodikk@DESKTOP-MJQ2MP4:~$ bitcoin-cli -regtest generate 1
[
  "7293bd3d3f9a175a2e2f03c941659e0680a8b7f42a9ba43976ae4f67e64a36e7"
]



dodikk@DESKTOP-MJQ2MP4:~$ bitcoin-cli -regtest listunspent | grep bca213de3e96254cf0840566ab375c2b1d6640d7bcf045d738c2a444e33f3e26
    "txid": "bca213de3e96254cf0840566ab375c2b1d6640d7bcf045d738c2a444e33f3e26",
    "txid": "bca213de3e96254cf0840566ab375c2b1d6640d7bcf045d738c2a444e33f3e26",
1 Like

After sending a Bitcoin transaction, how can wallet check the confirmation status? and How to check the transaction fee?

Confirmation status is about how many blocks have been mined on top of your block. So you can check that by checking the block height.

I think different wallets use different methods for calculating the fee. You can base it both on the current mempool or on previous blocks. You can read this blog post if you want to get a full picture: https://bitcointechtalk.com/an-introduction-to-bitcoin-core-fee-estimation-27920880ad0

As pointed out by @cata on the other thread, generate has become deprecated in bitcoin 0.18, get one of your addresses or a new one and generate a new block with ./bitcoin-cli -regtest generatetoaddress 1 <your_address>

Thank you for noticing. I’ve added some text about that.

2 Likes

Hey, I got this from my last tx
“txid”: “ac6a637be042707117ec8262d32fdacc375d0599b455f5a67680fa9e19d214f8”,
“vout”: 1,

Didn`t you say that vout is always 0?

Thanks

Hey,

Can you please help? I cannot figure out what the error is

I got an error message:
error: Error parsing JSON:{“2NBsVSyyPt3VmJBeJGVHxkHx7L17ebt5qms”: 5,}

Here`s my code:
./bitcoin-cli -regtest createrawtransaction ‘[{“txid”: “a5c882ee895b4983b7fef6f6a91d214965df124956269d568f976b5854c7c1f7”,“vout”: 0}]’ ‘{“2NBsVSyyPt3VmJBeJGVHxkHx7L17ebt5qms”: 5,}’

No, it’s not always zero. vout is the number outputs in that tx.

1 Like