You should not have the comma after the five. That indicates something is coming after it, but in your case. The 5 is the end of the object. So you should just have nothing
Yes! That worked, thanks a lot!
When I made the locking script I got a much shorter "asm"code than you?
“vin”: [
{
“txid”: “a5c882ee895b4983b7fef6f6a91d214965df124956269d568f976b5854c7c1f7”,
“vout”: 0,
“scriptSig”: {
“asm”: “0014fb660c11feb2e6a4ba4ace215599ac7dbe984e4a”,
Also when I made the unlocking script I did not get the OP_CHECKSIG but I got OP_EQUAL instead. Any idea why?
“vout”: [
{
“value”: 10.00000000,
“n”: 0,
“scriptPubKey”: {
“asm”: “OP_HASH160 cc4e24f52c784fffb09b315ed48702cbcbc25069 OP_EQUAL”,
First of all you have the two mixed up. The first one is your unlocking script and the second part is your locking script.
If you look at my locking script (in part 2), you will see I also have OP_EQUAL.
But your unlocking script looks a little bit weird, did you sign it? Can you send your entire signed transaction here. Please send it using the code format here in the forum.
First I
listed my unspent transactions and picked this one:
{
"txid":
“a5c882ee895b4983b7fef6f6a91d214965df124956269d568f976b5854c7c1f7”,
"vout": 0,
"address":
“2MuZFcnDYT5AVnvMkXQjZiiBLqxPdtDFSzK”,
"label": "",
"redeemScript":
“0014fb660c11feb2e6a4ba4ace215599ac7dbe984e4a”,
"scriptPubKey":
“a91419591952119e85d4186b24496bbb1c842edffbc587”,
"amount": 25.00000000,
"confirmations": 101,
"spendable": true,
"solvable": true,
"desc":
“sh(wpkh([ecf267e4/0’/0’/2’]0344dd2eb0e908cd0624e18281a2aeccde1de8a20b4e06279a78657c31708ca9d9))#gasgq3jv”,
"safe": true
},
Then I used
the command getnewaddress:
2NCKJydykRGfCvG7bNuJtAnQ1emGSEhkYEr
Then I made
the string in Atom and input txid and new wallet address into string:
‘[{“txid”:
“a5c882ee895b4983b7fef6f6a91d214965df124956269d568f976b5854c7c1f7”,“vout”:
0}]’ ‘{“2NCKJydykRGfCvG7bNuJtAnQ1emGSEhkYEr”: 10}’
Then I:
createrawtransaction using the string above and got:
0200000001f7c1c754586b978f569d26564912df6549211da9f6f6feb783495b89ee82c8a50000000000ffffffff0100ca9a3b0000000017a914d13037de674c958f20a19468264bd462cb0614ac8700000000
I then used
the signtransactionwithwallet and got:
02000000000101f7c1c754586b978f569d26564912df6549211da9f6f6feb783495b89ee82c8a50000000017160014fb660c11feb2e6a4ba4ace215599ac7dbe984e4affffffff0100ca9a3b0000000017a914d13037de674c958f20a19468264bd462cb0614ac870247304402200cc9f29abcca9eb3d4c1f86284944727e5e6cce698cb7a40afbec42994016dc302203e99b78da69bbd07f1dcd36f891f331d314c453986f69d33deafcf37116c545b01210344dd2eb0e908cd0624e18281a2aeccde1de8a20b4e06279a78657c31708ca9d900000000
I then
decoded the transaction after signing it:
PS
F:\Bitcoin Core\Bitcoin\daemon> ./bitcoin-cli -regtest decoderawtransaction
02000000000101f7c1c754586b978f569d26564912df6549211da9f6f6feb783495b89ee82c8a50000000017160014fb660c11feb2e6a4ba4ace215599ac7dbe984e4affffffff0100ca9a3b0000000017a914d13037de674c958f20a19468264bd462cb0614ac870247304402200cc9f29abcca9eb3d4c1f86284944727e5e6cce698cb7a40afbec42994016dc302203e99b78da69bbd07f1dcd36f891f331d314c453986f69d33deafcf37116c545b01210344dd2eb0e908cd0624e18281a2aeccde1de8a20b4e06279a78657c31708ca9d900000000
{
“txid”:
“d04b336a2963ab3d5aced77edb6a967af8eae3d8f402dcee2b2d5e3537313ed5”,
“hash”: “941c5cc29bf1da825f1646413e5d8d86c8f47a1bd9b7d77a0ef96952a4f82c8e”,
“version”: 2,
“size”: 215,
“vsize”: 134,
“weight”: 533,
“locktime”: 0,
“vin”: [
{
"txid":
“a5c882ee895b4983b7fef6f6a91d214965df124956269d568f976b5854c7c1f7”,
"vout": 0,
"scriptSig": {
"asm":
“0014fb660c11feb2e6a4ba4ace215599ac7dbe984e4a”,
"hex":
“160014fb660c11feb2e6a4ba4ace215599ac7dbe984e4a”
},
"txinwitness": [
“304402200cc9f29abcca9eb3d4c1f86284944727e5e6cce698cb7a40afbec42994016dc302203e99b78da69bbd07f1dcd36f891f331d314c453986f69d33deafcf37116c545b01”,
“0344dd2eb0e908cd0624e18281a2aeccde1de8a20b4e06279a78657c31708ca9d9”
],
"sequence": 4294967295
}
],
“vout”: [
{
"value": 10.00000000,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160
d13037de674c958f20a19468264bd462cb0614ac OP_EQUAL",
"hex":
“a914d13037de674c958f20a19468264bd462cb0614ac87”,
"reqSigs": 1,
"type": "scripthash",
"addresses": [
“2NCKJydykRGfCvG7bNuJtAnQ1emGSEhkYEr”
]
}
}
]
}
Here`s
where your vin scriptsig “asm” is much longer than my and without the [ALL] at
the end.
My thougth
is that this is my unlocking script since it`s the vin “asm”, is it not?
“vin”: [
{
"txid":
“a5c882ee895b4983b7fef6f6a91d214965df124956269d568f976b5854c7c1f7”,
"vout": 0,
"scriptSig": {
"asm":
“0014fb660c11feb2e6a4ba4ace215599ac7dbe984e4a”,
“vout”:
[
{
"value": 10.00000000,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160
d13037de674c958f20a19468264bd462cb0614ac OP_EQUAL",
Then I put
the original txid into the gettxout:
PS
F:\Bitcoin Core\Bitcoin\daemon> ./bitcoin-cli -regtest gettxout
“a5c882ee895b4983b7fef6f6a91d214965df124956269d568f976b5854c7c1f7”, 0
{
“bestblock”:
“2d03fe757d5dd3670b044e83702c4a9bc526993e560aa3808521e4e085f16bd9”,
“confirmations”: 101,
“value”: 25.00000000,
“scriptPubKey”: {
"asm": "OP_HASH160
19591952119e85d4186b24496bbb1c842edffbc5 OP_EQUAL",
"hex":
“a91419591952119e85d4186b24496bbb1c842edffbc587”,
"reqSigs": 1,
"type": "scripthash",
"addresses": [
“2MuZFcnDYT5AVnvMkXQjZiiBLqxPdtDFSzK”
]
},
“coinbase”: true
I put the
the locking script below from the gettxout “asm” command, did I misunderstand
this? This does not look right, but I can not tell why
UNLOCKING: 0014fb660c11feb2e6a4ba4ace215599ac7dbe984e4a
LOCKING: OP_HASH160
19591952119e85d4186b24496bbb1c842edffbc5 OP_EQUAL
Ok, thanks. Now it makes more sense. Your unlocking script is different because yours is a segwit transaction. So your signature is in the witness field, as you can see in your signed transaction. So that’s why your unlocking script is shorter.
It seems that there has been a new release of bitcoind (version 0.18) that changes how it handles witness scripts. But I’m confused why your coinbase transaction gave you 25 bitcoin instead of 50, I don’t understand why that would happen.
But there is nothing wrong with your transaction. Everything looks fine.
Hi Filip, i have some questions. My result is different compared to the videopart 3:
I have my signature in txinwitness:
PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest signrawtransactionwithwallet 020000000134f6d8abf728844632d50fe0bf42db6382bb8eaeb824a7e2965190e332cd58d00000000000ffffffff01001110240100000017a914fa8c9783a0c55109c991f2ec24b63c1bd9602b648700000000
{
“hex”: “0200000000010134f6d8abf728844632d50fe0bf42db6382bb8eaeb824a7e2965190e332cd58d00000000017160014fc980f16db921697c0bfe8c3711fd27c7a9f26c1ffffffff01001110240100000017a914fa8c9783a0c55109c991f2ec24b63c1bd9602b64870247304402203125f4b36fab4033b91e2ce2009018cd235b9c2f3f3ea8437817e702f167206d02202198d3dbd34ba8e23b1707a9789faee8c7d9f1ffdbd008ea55fd8ac9cd1ffdc1012103342631815b73e73cb5696d32db5be46248f3343543a13a1b28b6c642a7a6b8e300000000”,
“complete”: true
}
PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest decoderawtransaction 0200000000010134f6d8abf728844632d50fe0bf42db6382bb8eaeb824a7e2965190e332cd58d00000000017160014fc980f16db921697c0bfe8c3711fd27c7a9f26c1ffffffff01001110240100000017a914fa8c9783a0c55109c991f2ec24b63c1bd9602b64870247304402203125f4b36fab4033b91e2ce2009018cd235b9c2f3f3ea8437817e702f167206d02202198d3dbd34ba8e23b1707a9789faee8c7d9f1ffdbd008ea55fd8ac9cd1ffdc1012103342631815b73e73cb5696d32db5be46248f3343543a13a1b28b6c642a7a6b8e300000000
{
“txid”: “bbf9e83f342a1a61a99ccd804b2b614dfe9b8364976920d26252f6dbb6891e91”,
“hash”: “7687acce64a2941defc4042c0c5343517bb4b1bd80a5f8011c0a611563bc92e1”,
“version”: 2,
“size”: 215,
“vsize”: 134,
“weight”: 533,
“locktime”: 0,
“vin”: [
{
“txid”: “d058cd32e3905196e2a724b8ae8ebb8263db42bfe00fd532468428f7abd8f634”,
“vout”: 0,
“scriptSig”: {
“asm”: “0014fc980f16db921697c0bfe8c3711fd27c7a9f26c1”,
“hex”: “160014fc980f16db921697c0bfe8c3711fd27c7a9f26c1”
},
“txinwitness”: [
“304402203125f4b36fab4033b91e2ce2009018cd235b9c2f3f3ea8437817e702f167206d02202198d3dbd34ba8e23b1707a9789faee8c7d9f1ffdbd008ea55fd8ac9cd1ffdc101”,
“03342631815b73e73cb5696d32db5be46248f3343543a13a1b28b6c642a7a6b8e3”
],
“sequence”: 4294967295
}
],
“vout”: [
{
“value”: 49.00000000,
“n”: 0,
“scriptPubKey”: {
“asm”: “OP_HASH160 fa8c9783a0c55109c991f2ec24b63c1bd9602b64 OP_EQUAL”,
“hex”: “a914fa8c9783a0c55109c991f2ec24b63c1bd9602b6487”,
“reqSigs”: 1,
“type”: “scripthash”,
“addresses”: [
“2NG61LjZo9s23ZNtpxoBzDBQGVJYvhZKvwi”
]
}
}
]
}
Hi Filip, in video part 4 you stated that gettxout should give an OP_CHECKSIG. This is my result:
PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest listunspent
[
{
“txid”: “d058cd32e3905196e2a724b8ae8ebb8263db42bfe00fd532468428f7abd8f634”,
“vout”: 0,
“address”: “2N72N9ko7LjDaizKkiL2XJd3fsGry67Xf5r”,
“label”: “”,
“redeemScript”: “0014fc980f16db921697c0bfe8c3711fd27c7a9f26c1”,
“scriptPubKey”: “a91497232af8b0cb2d7769981c1cbc123ef1c7b86e9787”,
“amount”: 50.00000000,
“confirmations”: 106,
“spendable”: true,
“solvable”: true,
“desc”: “sh(wpkh([3cb8d47d/0’/0’/3’]03342631815b73e73cb5696d32db5be46248f3343543a13a1b28b6c642a7a6b8e3))#r47dm9v5”,
“safe”: true
},
{
“txid”: “fbad73ef559fb4363a15e15a9dbbd605f24f6dee82268392b1fa9e74af38c380”,
“vout”: 0,
“address”: “2N59pJXpn8jdtaoUAKXoVP69y2TXigmXqZZ”,
“redeemScript”: “00148a07bb7697e778a7369a0b2480c4dd5ae33762ac”,
“scriptPubKey”: “a914829ba8756e854e89d181a7bc223a487900a0a13687”,
“amount”: 39.99987620,
“confirmations”: 1,
“spendable”: true,
“solvable”: true,
“desc”: “sh(wpkh([3cb8d47d/0’/1’/0’]024228b1e83ad58472ed7383e5bb4c97332114185f84e61fdb778b79ef25867f93))#zr0d0ry0”,
“safe”: true
},
{
“txid”: “fbad73ef559fb4363a15e15a9dbbd605f24f6dee82268392b1fa9e74af38c380”,
“vout”: 1,
“address”: “2N5hQLHz8zGe7UZaS3uHiQ7hxotTUePq7jC”,
“label”: “”,
“redeemScript”: “0014e163ea747ce8bc6708cc50948ab60c265384e001”,
“scriptPubKey”: “a9148894f5c12bf1e7839aa7af888c566c8829fb19e887”,
“amount”: 260.00000000,
“confirmations”: 1,
“spendable”: true,
“solvable”: true,
“desc”: “sh(wpkh([3cb8d47d/0’/0’/4’]0286a3360cb4333c3c06d3589467dbdd2928ee3dc4f0dc5ff8fbce4c0538a5ad75))#fxfu6jug”,
“safe”: true
},
{
“txid”: “6c98b0cc57eb389b49ca27f19020be2782eae2e92fdd7182d1a03f28d782bbbf”,
“vout”: 0,
“address”: “2N72N9ko7LjDaizKkiL2XJd3fsGry67Xf5r”,
“label”: “”,
“redeemScript”: “0014fc980f16db921697c0bfe8c3711fd27c7a9f26c1”,
“scriptPubKey”: “a91497232af8b0cb2d7769981c1cbc123ef1c7b86e9787”,
“amount”: 50.00000000,
“confirmations”: 101,
“spendable”: true,
“solvable”: true,
“desc”: “sh(wpkh([3cb8d47d/0’/0’/3’]03342631815b73e73cb5696d32db5be46248f3343543a13a1b28b6c642a7a6b8e3))#r47dm9v5”,
“safe”: true
}
]
PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest gettxout “d058cd32e3905196e2a724b8ae8ebb8263db42bfe00fd532468428f7abd8f634”, 0
{
“bestblock”: “649f43d2179763053534d1271115f83ad5ff0932a3d3473b29ab7f28046f0a59”,
“confirmations”: 106,
“value”: 50.00000000,
“scriptPubKey”: {
“asm”: “OP_HASH160 97232af8b0cb2d7769981c1cbc123ef1c7b86e97 OP_EQUAL”,
“hex”: “a91497232af8b0cb2d7769981c1cbc123ef1c7b86e9787”,
“reqSigs”: 1,
“type”: “scripthash”,
“addresses”: [
“2N72N9ko7LjDaizKkiL2XJd3fsGry67Xf5r”
]
},
“coinbase”: true
}
Why do i get OP_EQUAL?
To answer your first question, there seems to have been an update to bitcoind so it now creates segwit transactions by default. That’s why your signature is in witness. Not a problem, just looks different.
The answer to your second question is also very similar to the first answer. Seems like there has been an update so that the standard tx’s now are P2SH tx’s. So it’s a different type of locking script. Also nothing that is wrong on your part. Just an update in the software
How do you protect the .json file when you create transactions? How do you know the address is not changed when you pass the json file to bitcoincli?
Do you mean how we can protect us from if bitcoincli program would have a bug or exploit that would modify the input we send to it? We would have to verify the bitcoincli code ourselves and then compile that code for ourselves. Or we could trust the bitcoin developers to do it.
It is not the bitcoincli I am worried about…
If you save the transaction as json file and you pass the json file to the bicoincli…
If a malicious application modifies the address in the json file, it will be too late as you had already passed the file to bitcoin-cli to be processed.
Yes, if you are worried about that you could just copy the json string and input it straight into the command line.
Would it be possible to view the video that you made of how to write a raw transaction in OSX?
It would be nice to see the same demonstration for Mac or Linux since nearly all of my full node operation up to this point has been in those environments.
Also, I think that in order for the steps to perform correctly (based on recent updates), when generating addresses “getnewaddress legacy” should be used, otherwise it creates a segwit address and behaves a little differently (not a big deal based on what we know at this point). Am I correct in my thinking here?
Unfortunately I don’t have any video on that. I used a virtual machine with Windows since most people will be using Windows. But the commands are the same. If I remember correctly, the only thing that was different was how the terminal interpreted json, which was a bit trickier in windows.
Yeah if you want the exact same result you should use that. But seems like the new command works fine as well together with the videos, but the raw transaction will look slightly different.
Hi, my first post
You answer a couple of questions saying that bitcoind was updated to create segwit txns by default. Please can you explain what part(s) of which field(s) in the currently generated decodedrawtransaction need to be extracted and put into the Bitcoin IDE (asm tab I presume) for script simulation along with the unlocking script from the unspent output? I have tried a few combinations without success, and I think it would be useful for people, like me, trying to follow on in lockstep with the videos (but verifying at every stage with the IDE for fuller understanding). Thanks!
i can see this is going to be tricky enough @filip for a while till i figure out all the difference between the way i have to do things in linux when its explained from a windows perspective. so in linux for gettxout no quotes and no commas haha.
thanks @filip that was heavy going. good bit of debugging to do getting it working on linux terminal and was a bit hard keeping up with what was going where between txid’s signed tx hasshes and locking scripts but i get it now. i think i have a basic handle of how it pieces together now. will do a few transactions on my own now to cement the knowledge after a good rest.
Hi, is anyone reading recent queries?