Closed C-Otto closed 2 years ago
Can you simplify the example or provide a pointer to history.sh
? Reproducing this bug is the first step to solving it.
Sorry, I hoped the stack trace helped you see the entry point. Here's the history.py
(called from history.sh
): https://github.com/romanz/electrs/blob/master/contrib/history.py
As far as I can see, this just tries to get the script for the given address, using the mainnet BTC chain details:
network.parse.address(addr).script()
Okay, so here's a minimal failure case:
python3 -c 'from pycoin.symbols.btc import network; network.parse.address("bc1p9l9dw3cz09jje30c3wysseuddax40t6kyuvrkqlusszvknskmzys00k7zm")'
Even easier: coinc 'PUSH_81'
Okay, looks like PUSH_81
isn't a real operator. Try this patch and see if it helps:
--- a/pycoin/networks/ContractAPI.py
+++ b/pycoin/networks/ContractAPI.py
@@ -93,7 +93,7 @@ class ContractAPI(object):
p2pkh_wit=lambda info: "OP_0 %s" % b2h(info.get("hash160")),
p2sh=lambda info: "OP_HASH160 %s OP_EQUAL" % b2h(info.get("hash160")),
p2sh_wit=lambda info: "OP_0 %s" % b2h(info.get("hash256")),
- p2tr=lambda info: "PUSH_81 %s" % b2h(info.get("synthetic_key")),
+ p2tr=lambda info: "OP_1 %s" % b2h(info.get("synthetic_key")),
multisig=lambda info: "%d %s %d OP_CHECKMULTISIG" % (
info.get("m"), " ".join(b2h(sk) for sk in info.get("sec_keys")), len(info.get("sec_keys"))),
)
I now get
% python3 -c 'from pycoin.symbols.btc import network; print(network.parse.address("bc1p9l9dw3cz09jje30c3wysseuddax40t6kyuvrkqlusszvknskmzys00k7zm").script().hex())'
51202fcad7470279652cc5f88b8908678d6f4d57af5627183b03fc8404cb4e16d889
which seems less bad.
Thanks, this looks reasonable to me:
cotto@home:~/git/electrs/contrib (master)$ ./history.sh --venv bc1p9l9dw3cz09jje30c3wysseuddax40t6kyuvrkqlusszvknskmzys00k7zm
[2022-02-14 08:27:03.221573] INFO: electrum: connecting to localhost:50001
[2022-02-14 08:27:03.312897] INFO: electrum: subscribed to 1 scripthashes
[2022-02-14 08:27:03.319916] INFO: electrum: got history of 8 transactions
[2022-02-14 08:27:03.322742] INFO: electrum: loaded 8 transactions
[2022-02-14 08:27:03.324387] INFO: electrum: loaded 4 header timestamps
[2022-02-14 08:27:03.366496] INFO: electrum: loaded 8 merkle proofs
+------------------------------------------------------------------+----------------------+--------+---------------+--------------+--------------+
| txid | block timestamp | height | confirmations | delta (mBTC) | total (mBTC) |
+------------------------------------------------------------------+----------------------+--------+---------------+--------------+--------------+
| 5b79f5d6039c188613342eb13961dd7d1e1a0f90023d3eaed25fc85a29201bb4 | 2021-11-14T05:15:27Z | 709632 | 13613 | 0.07500 | 0.07500 |
| 905ecdf95a84804b192f4dc221cfed4d77959b81ed66013a7e41a6e61e7ed530 | 2021-11-14T05:40:13Z | 709635 | 13610 | -0.07500 | 0.00000 |
| aaef6c5fdece5f7ff7614173e057148ea9b737a4a25c2b3b06da5b963ab29c4c | 2021-11-14T05:50:37Z | 709636 | 13609 | 0.07500 | 0.07500 |
| 1ec1bc93dcf19ef972fe7083393d188387cff24203d07ad98bcba776e8fd87ac | 2021-11-14T05:50:37Z | 709636 | 13609 | -0.07500 | 0.00000 |
| 68d0aa3e3afd7311d25e026d026b2190d4814556653c4d01c849bc2b177a6b44 | 2021-11-14T05:50:37Z | 709636 | 13609 | 0.07500 | 0.07500 |
| 94fff3594c1ac2bca92bd1a23544af99e46e5c70726b57181d504f99d65add80 | 2021-11-14T05:50:37Z | 709636 | 13609 | -0.07500 | 0.00000 |
| 915181151c955214318bff2323e13a3f0d37013333644193b6dac0b31f905b94 | 2021-11-14T05:50:37Z | 709636 | 13609 | 0.07500 | 0.07500 |
| 3bb0608088450c137906a653fb62f180178580587bd02712d7ecafb7385f9c16 | 2021-11-14T05:53:34Z | 709638 | 13607 | -0.07500 | 0.00000 |
+------------------------------------------------------------------+----------------------+--------+---------------+--------------+--------------+
[2022-02-14 08:27:03.367258] INFO: electrum: tip=000000000000000000048afc60197f3b9c647e1b663f89cedf105b294d201f15, height=723244 @ 2022-02-14T08:24:58Z
This matches the output I get from mempool.space:
https://mempool.space/address/bc1p9l9dw3cz09jje30c3wysseuddax40t6kyuvrkqlusszvknskmzys00k7zm
I realize that P2TR has beta support, and you might be aware of this. Sorry in advance.
I'm using a
history.sh
example from electrs, which uses pycoin to get the script for a given address. This fails for bc1p9l9dw3cz09jje30c3wysseuddax40t6kyuvrkqlusszvknskmzys00k7zm: