Comments (10)
Yeah, I should probably mention that in the readme. You need to include the transaction and the amount(s) for the debugger to be able to do signature check operations.
from btcdeb.
Thanks @kallewoof
Another combination that worked for me and I found it very useful is to run your script debugger with the transaction hex and the script. The debugger parses the transaction and the amounts for me so I don't have to specify the amounts. Go btcdeb!!!
./btcdeb --tx=0200000001614fde1883bb8ed6e2393d8b1c69905703a46020d99209455ee0bd51c12f5a160000000049483045022100e2866f9b931ebceb65cfa6a98d7f99da66dccd730607e49d3e2a565ab77ca2c002200354d003ee1035d3fed1f212388e8ff11595f7c507c740ea10c95a3e92f44b3901feffffff020065cd1d0000000017a9146efa51adc514938f7e8d477c79e771c29b53558987d008b42c0000000017a914542ca0ab1c5c254ff4adaefa312fa5ae4e0f616087f4010000 '[3045022100e2866f9b931ebceb65cfa6a98d7f99da66dccd730607e49d3e2a565ab77ca2c002200354d003ee1035d3fed1f212388e8ff11595f7c507c740ea10c95a3e92f44b3901 03d82ee81d86ab352633839e6d2e58e8e3760a51f67289072bcb243d56fd0fed5a OP_CHECKSIG]'
from btcdeb.
Was the input non-segwit? If so, I think you can skip amounts, as they're only checked for segwit transactions. :)
from btcdeb.
Got it. Yes, it was non-segwit. Thanks @kallewoof for your answers and the script debugger.
from btcdeb.
Hi @kallewoof
In signature checking topic, it would be great if you can give an example of how to run the debugger with the amount values for the segwit transactions when you find some time. Are the amounts from the output of tx or from the output of txin? Are the amounts in satoshis or bitcoins? I tried all 4 combinations and I couldn't get it to work. Thanks in advance.
from btcdeb.
Have you tried the tutorials at https://github.com/ChristopherA/Learning-Bitcoin-from-the-Command-Line ?
from btcdeb.
@tun-chang The tutorials mentioned by @ChristopherA do have examples of this. I'll see about adding them here in the local readme as well. Can you send me an example that doesn't work for you?
from btcdeb.
@ChristopherA , yes I've tried the tutorials from your book. I read through "Bitcoin Scripting" chapters 7-11. I couldn't find the example I was looking for. I really liked your book by the way. It's really hands-on and introduced me to btcdeb.
@kallewoof , the example I am trying out has the following tx and txin.
btcdeb --tx=0100000001186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779000000008b483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adfffffffff0260e31600000000001976a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788acd0ef8000000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000 --txin=0100000001524d288f25cada331c298e21995ad070e1d1a0793e818f2f7cfb5f6122ef3e71000000008c493046022100a59e516883459706ac2e6ed6a97ef9788942d3c96a0108f2699fa48d9a5725d1022100f9bb4434943e87901c0c96b5f3af4e7ba7b83e12c69b1edbfe6965f933fcd17d014104e5a0b4de6c09bd9d3f730ce56ff42657da3a7ec4798c0ace2459fb007236bc3249f70170509ed663da0300023a5de700998bfec49d4da4c66288a58374626c8dffffffff0180969800000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000
With the raw hex'es, I was able to run fine. But I wanted to run with the script like the following but I cannot get it to work. I tried with amounts from the output of tx as well as the output of txin. I also tried the amounts in satoshis and bitcoins. Thank you for your help. I really appreciate it.
btcdeb --tx=0.01500000,0.08450000:0100000001186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779000000008b483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adfffffffff0260e31600000000001976a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788acd0ef8000000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000 '[3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301 0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf OP_DUP OP_HASH160 7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8 OP_EQUALVERIFY OP_CHECKSIG]'
from btcdeb.
@tun-chang Sorry for late reply. The input amount should be 0.1. There's only one input so you only need the one.
There's another issue in your code, though; the script itself is actually passed to the signing module and is a part of the signature hash. In your case, your script includes pushing the pubkey and signature, which is different from the input script! Instead what you do is put the pushed content after the script in the call to btcdeb; the base syntax is btcdeb [script] [stack 1] [stack 2] [...]
. So the actual output becomes:
btcdeb \
--tx=0.1:0100000001186f9f998a5aa6f048e51dd8419a14d8a0f1a8a2836dd734d2804fe65fa35779000000008b483045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301410484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adfffffffff0260e31600000000001976a914ab68025513c3dbd2f7b92a94e0581f5d50f654e788acd0ef8000000000001976a9147f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a888ac00000000 \
'[OP_DUP OP_HASH160 7f9b1a7fb68d60c536c2fd8aeaa53a8f3cc025a8 OP_EQUALVERIFY OP_CHECKSIG]' \
3045022100884d142d86652a3f47ba4746ec719bbfbd040a570b1deccbb6498c75c4ae24cb02204b9f039ff08df09cbe9f6addac960298cad530a863ea8f53982c09db8f6e381301 \
0484ecc0d46f1918b30928fa0e4ed99f16a0fb4fde0735e7ade8416ab9fe423cc5412336376789d172787ec3457eee41c04f4938de5cc17b4a10fa336a8d752adf
Now, the way you can figure this out is to use the environment variables DEBUG_SIGHASH
and DEBUG_SIGNING
. Try running your two variants like this:
DEBUG_SIGNING=1 DEBUG_SIGHASH=1 btcdeb [...]
You will see that the script code differs.
from btcdeb.
@kallewoof Thank you very much. I get it now. Thanks also for DEBUG_SIGHASH
and DEBUG_SIGNING
tip. These debug flags and logs are really helpful.
from btcdeb.
Related Issues (20)
- make fails HOT 11
- glibtoolize: error: One of these is required: glibtoolize: gm4 gnum4 m4 glibtoolize: error: Please install GNU M4, or 'export M4=/path/to/gnu/m4'.
- Doc Tapscript Example with Tap - Error: Invalid Script HOT 2
- Script pubkey version 1 not supported when debugging taproot transaction in v0.3.20 HOT 2
- Need a correction in Read.me - docker commands HOT 1
- Docker container fails to run HOT 2
- How to get input hex for --txin= ? HOT 5
- .
- how can i use lib on testnet HOT 3
- .
- .
- Problems compiling btcdeb tools into JavaScript using emscripten. HOT 1
- P2TR transaction Signature checking error HOT 4
- error: Using OP_CODESEPARATOR in non-witness script HOT 1
- Alomado
- Napolitano
- Linux installation issue HOT 5
- Hi
- Would this gonna fix the transaction?
- c
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from btcdeb.