Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug-fix: taproot debugging #90

Merged
merged 2 commits into from
Nov 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/tapscript-example-with-tap.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ $ bcli getrawtransaction ec409014a3b1e7171cf498726bc7bc8bd249a04b65f30c7b8cb5c30

This will be our input transaction. Make note of the index in the vout array of our output -- in this case it is index 0. We need to keep that index and that hex value around, so let's save those as environment variables:
```Bash
$ vin=0 # CONFIRM THIS OR THINGS WILL FAIL
$ vout=0 # CONFIRM THIS OR THINGS WILL FAIL
$ txin=020000000001010aa633878f200c80fc8ec88f13f746e5870be7373ad5d78d22e14a402d6c6fc20000000000feffffff02a086010000000000225120a5ba0871796eb49fb4caa6bf78e675b9455e2d66e751676420f8381d5dda8951c759f405000000001600147bf84e78c81b9fed7a47b9251d95b13d6ebac14102473044022017de23798d7a01946744421fbb79a48556da809a9ffdb729f6e5983051480991022052460a5082749422804ad2a25e6f8335d5cf31f69799cece4a1ccc0256d5010701210257e0052b0ec6736ee13392940b7932571ce91659f71e899210b8daaf6f17027500000000
```

Expand All @@ -173,7 +173,7 @@ First, we need to create a transaction that spends from these inputs.
```Bash
$ bcli getnewaddress
bcrt1qe6ed9zhaetg6ur7ze7quhy5m520gx35znudxan
$ tx=$(bcli createrawtransaction '[{"txid":"ec409014a3b1e7171cf498726bc7bc8bd249a04b65f30c7b8cb5c3079cf8f271", "vout":0}]' '[{"bcrt1qe6ed9zhaetg6ur7ze7quhy5m520gx35znudxan":0.0009}]')
$ tx=$(bcli createrawtransaction '[{"txid":"ec409014a3b1e7171cf498726bc7bc8bd249a04b65f30c7b8cb5c3079cf8f271", "vout":$vout}]' '[{"bcrt1qe6ed9zhaetg6ur7ze7quhy5m520gx35znudxan":0.0009}]')
$ echo $tx
020000000171f2f89c07c3b58c7b0cf3654ba049d28bbcc76b7298f41c17e7b1a3149040ec0000000000ffffffff01905f010000000000160014ceb2d28afdcad1ae0fc2cf81cb929ba29e83468200000000
```
Expand Down
1 change: 1 addition & 0 deletions doc/txs/p2tr-in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
02000000000101e8f6e9842ef28c0cd13aeda574a1c81cd901685a7fa9088928cabde5ce1c3da90000000000feffffff02c759f40500000000160014a6e938b0815930ba6a7a79a1b3af38769adf405ea086010000000000225120a5ba0871796eb49fb4caa6bf78e675b9455e2d66e751676420f8381d5dda89510247304402202fc3f24bf7288031677ddfab0124e4a4f61b35429e48f0144a15e742e7c9b12a022063db1de6fde01117fe492824397305b6d3919edb29da6bbbd451fcc0fe0a1fab01210257e0052b0ec6736ee13392940b7932571ce91659f71e899210b8daaf6f17027500000000
1 change: 1 addition & 0 deletions doc/txs/p2tr-tx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
02000000000101b24f16ad8fcc61be2e329b405d578fb773cc3ee5fdbdba59be2e919f1a216a990100000000ffffffff01905f0100000000001600145f4c6989b4059186244d02e77551dddd96c96a7701400fcc6202036476acaf4d464fa21b586f9430634e995269ba1e844311a4d44db4b18ecdbf9934da968100df40c45c43b39f76e47d924bf132736a80cf50c5ec3200000000
2 changes: 1 addition & 1 deletion instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ bool Instance::setup_environment(unsigned int flags) {
if (tx) {
if (txin && txin_index > -1) {
std::vector<CTxOut> spent_outputs;
spent_outputs.emplace_back(txin->vout[txin_index]);
spent_outputs.emplace_back(txin->vout[txin_vout_index]);
if (tx->vin.size() == 1) {
txdata.Init(*tx.get(), std::move(spent_outputs), has_preamble);
}
Expand Down
6 changes: 6 additions & 0 deletions instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class Instance {
ECCVerifyHandle evh;
CTransactionRef tx;
CTransactionRef txin;
/*
* INPUT TX VOUT TX VIN
* [0] [0]* <-- txin_index==0
* [1]* [1]
* `-- txin_vout_index==1
*/
int64_t txin_index; ///< index of the input txid in tx's inputs
int64_t txin_vout_index; ///< index inside txin of the output to tx
std::vector<CAmount> amounts;
Expand Down