File tree 2 files changed +31
-10
lines changed
2 files changed +31
-10
lines changed Original file line number Diff line number Diff line change 10
10
11
11
jobs :
12
12
test :
13
- runs-on : ubuntu-20 .04
13
+ runs-on : ubuntu-24 .04
14
14
container : bigspider/bitcoin_matt
15
15
steps :
16
16
- name : Prepare Configuration File
@@ -20,24 +20,32 @@ jobs:
20
20
- name : Run MATT-enabled bitcoind
21
21
run : |
22
22
bitcoind -regtest --daemon
23
+ - name : Set up dependencies
24
+ run : |
25
+ apt-get update
26
+ apt-get install -y libssl-dev libffi-dev
27
+ apt-get install -y python3-venv
23
28
- name : Set up Python
24
29
uses : actions/setup-python@v2
25
30
with :
26
31
python-version : ' 3.10'
27
32
- name : Clone
28
33
uses : actions/checkout@v4
29
- - name : Install pip and pytest
34
+ - name : Install dependencies
30
35
run : |
31
- apt-get update
32
- apt-get install -y python3-pip
36
+ python -m venv venv
37
+ source venv/bin/activate
38
+ pip install --upgrade pip
33
39
pip install -r requirements-dev.txt
34
- - name : Install pymatt
35
- run : |
36
40
pip install .
41
+ shell : bash
37
42
- name : Create test wallet
38
43
run : bash ./examples/init.sh
39
44
- name : Run tests and capture output
40
- run : pytest -vv
45
+ run : |
46
+ source venv/bin/activate
47
+ pytest -vv
48
+ shell : bash
41
49
- name : Upload test output as artifact
42
50
uses : actions/upload-artifact@v4
43
51
with :
Original file line number Diff line number Diff line change
1
+ import hashlib
2
+
1
3
from abc import ABC , abstractmethod
2
4
from dataclasses import dataclass
3
5
from enum import Enum
11
13
from .btctools .segwit_addr import encode_segwit_address
12
14
13
15
16
+ def tweak_embed_data (key : bytes , data : bytes ) -> Optional [Tuple [bytes , Optional [bool ]]]:
17
+ """
18
+ Tweaks a key with the sha256 hash of the data, returning the tweaked key and whether the result had to be negated.
19
+ If the data is empty, the key is returned as is.
20
+ """
21
+
22
+ if len (data ) == 0 :
23
+ return key , None
24
+
25
+ data_tweak = hashlib .sha256 (key + data ).digest ()
26
+ return tweak_add_pubkey (key , data_tweak )
27
+
28
+
14
29
class AbstractContract :
15
30
pass
16
31
@@ -317,9 +332,7 @@ def get_taptree_merkle_root(self) -> bytes:
317
332
return self .get_tr_info (b'\0 ' * 32 ).merkle_root
318
333
319
334
def get_tr_info (self , data : bytes ) -> TaprootInfo :
320
- assert len (data ) == 32
321
-
322
- internal_pubkey , _ = tweak_add_pubkey (self .naked_internal_pubkey , data )
335
+ internal_pubkey , _ = tweak_embed_data (self .naked_internal_pubkey , data )
323
336
324
337
return script .taproot_construct (internal_pubkey , self .get_scripts ())
325
338
You can’t perform that action at this time.
0 commit comments