Creating a Raw Transaction - Discussion

Could somebody help me with how to write a code in linux for that please:’[{“txid”: “ca5ce8eb39a6010fab5561e2dc7cfab50d6f7d234bcff9825f2cd79ffc3cf3fe”,“vout”: 0}]’ ‘{“2MtgRgDJfuqXWxCn8RR1dyv3xeu4LJvmBR5”:49}’

Hello sir, could you please share a screenshot of the error that you are facing?

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

1 Like

Hey, thanks for help. I already figured it out:)

1 Like

Running on a MAC OSX.

Getting message ‘Could not connect to the server’ when executing a -REGTEST LISTUNSPENT command as shown below.

Please advise.

Thank you.

Hi, you must also start bitcoind using the regtest flag :slight_smile:

1 Like

Part 4 - Debugging Our Script

Executing using MAC OSX.

I am getting an ERROR message when using the GETTXOUT method ::

Remove the comma in the command :slight_smile: arguments are separated using space:

bitcoin-cli -regtest gettxout <TXID> 0
1 Like

Thank you, Alko89 - that worked …

1 Like

Part 5 - Sending Transaction

Executing on a MAC OSX.

ERROR message when trying to GENERATE a block ::

This command is deprecated, not sure if it has been fixed in the video yet. Sorry for that. :slight_smile:
To generate blocks on regtest you have to use generatetoaddress:

bitcoin-cli -regtest generatetoaddress 1 <ADDRESS>
1 Like

How do you do this with scriptsig not filled in but with txinwitness SEGWIT transaction?

> I just got the transaction sig in txwitness. Not in scriptsig.
> Am I assuming correctly that this is also correct but just a SEGWITted tx?

PS E:\Program Files\Bitcoin\daemon> .\bitcoin-cli -regtest decoderawtransaction 02000000000101f95328cb46dd36bd1ecd16ac890450515f83ad9d010d8462ee718311b45414080000000000ffffffff0100111024010000001600149277fb1bbfef83c2439a085ca0acd25b59f2499a0247304402200ec3f401ea6d94b5257f80a0574a2010c03540253acc432fe0cde36e69855775022055e782df27a10c034d606d670b2f6e613a6ab7e3aa4b02d09c768ce8b4027585012102c37de70e9fd8ced9699dfd2d22f1445aeb3f5f247d38813160040b518f03756800000000
{
“txid”: “0a4fa86dab21c838fa8c03f2de1de1df2747171aa0106fae435329041bf71844”,
“hash”: “f5849350fe04be1599a9982fc2b141e5be6c86b557e5bee43cc6740d57e3b3c0”,
“version”: 2,
“size”: 191,
“vsize”: 110,
“weight”: 437,
“locktime”: 0,
“vin”: [
{
“txid”: “081454b4118371ee62840d019dad835f51500489ac16cd1ebd36dd46cb2853f9”,
“vout”: 0,
“scriptSig”: {
“asm”: “”,
“hex”: “”
},
“txinwitness”: [
“304402200ec3f401ea6d94b5257f80a0574a2010c03540253acc432fe0cde36e69855775022055e782df27a10c034d606d670b2f6e613a6ab7e3aa4b02d09c768ce8b402758501”,
“02c37de70e9fd8ced9699dfd2d22f1445aeb3f5f247d38813160040b518f037568”
],
“sequence”: 4294967295
}
],
“vout”: [
{
“value”: 49.00000000,
“n”: 0,
“scriptPubKey”: {
“asm”: “0 9277fb1bbfef83c2439a085ca0acd25b59f2499a”,
“hex”: “00149277fb1bbfef83c2439a085ca0acd25b59f2499a”,
“reqSigs”: 1,
“type”: “witness_v0_keyhash”,
“addresses”: [
“bcrt1qjfmlkxala7puysu6ppw2ptxjtdvlyjv69c8emy”
]
}
}
]
}

1 Like

Yes this is a segwit tx. Its also a Bech32 tx, that is a bit more efficient on blockspace :slight_smile:

2 Likes

After a lot of mucking about I still can’t get this to work. The message I receive is;

PS C:\Users\User\Desktop\Crypto and Blockchain\bitcoin-0.20.1-win64\bitcoin-0.20.1\bin> ./bitcoin-cli -regtest createrawtransaction “[{“txid”:“6da741171fd6d378baafdc826346caf36d658550e3d9ce2be90690f56a65bcf6”,“vout”:0}]” “[“bcrt1qnfudsp7nghn600pavdm9hdjjtm39cyrnnrg4vj”:49]”

error: Error parsing JSON:[{

I notice that the four characters before the txid are greyed-out (namely the " [ { and " characters. And so are the " [ and " immediately before the bitcoin address. Maybe this has some bearing on it, but I can’t figure out what.

I have substituted ’ for ", and { for [ and ( I’ve also tried removing spaces etc.

Any advice would be appreciated.

Have you done this all at once? You shouldn’t substitute { and [ they are important to remain as they are.

Have you tried replacing only the starting and ending " to ’ the inner ones must also remain.
Like this:
'[{“txid”:“6da741171fd6d378baafdc826346caf36d658550e3d9ce2be90690f56a65bcf6”,“vout”:0}]” “[“bcrt1qnfudsp7nghn600pavdm9hdjjtm39cyrnnrg4vj”:49]'

Also I’m not sure if this is because of the forum or have you used the strange , they should be ". This is also important. :slight_smile:

2 Likes

I’m copying what you do to the letter, but I don’t get the same results. Instead I get;

PS C:\Users\User\Desktop\Crypto and Blockchain\bitcoin-0.20.1-win64\bitcoin-0.20.1\bin> ./bitcoin-cli -regtest decoderawtransaction 02000000000101e9838db4c764fa4489155689ca5a222c55a2f8e5bf10f2b9e7c76be4ce5722780000000000ffffffff01001110240100000016001459827adcbaf93594a520acc022d097f2598c07e102473044022035ede86b265307487227b7d1278bd553dc661100d087f158bee2264bc80ecb91022008609aff40df4c6f0eed9f9a13fc3d845f9570d85993bb344925e8964c4c932f01210250d500503539c5e4d418569e98cc089b648707df9eab8bed03b2743533a11b0100000000
{
“txid”: “7796650a646836eae4feae5a84bc8ae7d4dcf9c238332f5fed5bde22998acf52”,
“hash”: “bb15acbd0ab8f38803437a42f2060403116efe6c52db5cef2dd474f25c34294a”,
“version”: 2,
“size”: 191,
“vsize”: 110,
“weight”: 437,
“locktime”: 0,
“vin”: [
{
“txid”: “782257cee46bc7e7b9f210bfe5f8a2552c225aca8956158944fa64c7b48d83e9”,
“vout”: 0,
“scriptSig”: {
“asm”: “”,
“hex”: “”
},
“txinwitness”: [
“3044022035ede86b265307487227b7d1278bd553dc661100d087f158bee2264bc80ecb91022008609aff40df4c6f0eed9f9a13fc3d845f9570d85993bb344925e8964c4c932f01”,
“0250d500503539c5e4d418569e98cc089b648707df9eab8bed03b2743533a11b01”
],
“sequence”: 4294967295
}
],
“vout”: [
{
“value”: 49.00000000,
“n”: 0,
“scriptPubKey”: {
“asm”: “0 59827adcbaf93594a520acc022d097f2598c07e1”,
“hex”: “001459827adcbaf93594a520acc022d097f2598c07e1”,
“reqSigs”: 1,
“type”: “witness_v0_keyhash”,
“addresses”: [
“bcrt1qtxp84h96ly6efffq4nqz95yh7fvccplpa36ve7”
]
}
}
]
}

The “asm” and “hex” fields are empty. Instead I have a field called “txinwitness” which is filled.

Is this relevant, is it the result of an upgrade, or am I doing something wrong? If this is an upgrade, please advise on how I can continue with the course using this value instead of the “asm” and “hex”.

1 Like

Yes this is fine because you created a segwit transaction :slight_smile:

3 Likes

I had the same issue as above … also, it´s worth mentioning that the “asm” or the locking script is not written in OP code, but its also HEX. Could you please explain this @Alko89? Is it beacuse its a different transaction type, being a segwit Tx?

What did we do during this part of the course? I remember we had 3 block rewards (3x50BTC UTXO´s) and then, my understanding is that we sent 49 to a new address (of the same wallet) and 0.99 change to another address of the same wallet. What happened to the 0.1? that is missing? did it became a Tx fee? … and then we mined another block to put that Tx in the blockchain, thus creating another block reward of 50 BTC. Am I completely wrong?

The script is serialized, you would need to decode it to get the OP codes. You can use decodescript in bitcoin-cli or use one online https://live.blockcypher.com/btc/decodetx/

Yes if you constructed such a transaction than 0.1 was used as a transaction fee and you probably only used one of the 50 BTC UTXO available, not 3.
You should see the fee in the UTXO of the address you use when generating blocks. Mind that you will have to mine 100 blocks to see the output as spendable. You can also set the parameter in listunspent to show you the outputs that have less confirmations than required to be spent. :slight_smile:

bitcoin-cli help listunspent

1 Like

Thanks for the answer in the serialized script!!

Yes, I meant only one of the three … in fact, later I ran the listunspent instruction on the cli, and I could see the newly mined UTXO, the other 2 UTXO, and other 2 new UTXO´s: one for 49 BTC and another one for 0.99 BTC … that´s why I was asking what happened to the 0.1 extra … can I check the “miner balance” … I mean, suposedly this bitcoind Node it´s a full node, but as my understanding you would have to mine the blocks to put the into the blockchain, right? so, is the default wallet of the node the same as of the miner?