File tree Expand file tree Collapse file tree 3 files changed +34
-48
lines changed Expand file tree Collapse file tree 3 files changed +34
-48
lines changed Original file line number Diff line number Diff line change @@ -121,9 +121,6 @@ Utilities for manipulating transaction scripts (originally from python-bitcoinli
121
121
#### [ key.py] ( test_framework/key.py )
122
122
Test-only secp256k1 elliptic curve implementation
123
123
124
- #### [ bignum.py] ( test_framework/bignum.py )
125
- Helpers for script.py
126
-
127
124
#### [ blocktools.py] ( test_framework/blocktools.py )
128
125
Helper functions for creating blocks and transactions.
129
126
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 9
9
import hashlib
10
10
import struct
11
11
12
- from .bignum import bn2vch
13
12
from .messages import (
14
13
CTransaction ,
15
14
CTxOut ,
26
25
def hash160 (s ):
27
26
return hashlib .new ('ripemd160' , sha256 (s )).digest ()
28
27
28
+ def bn2vch (v ):
29
+ """Convert number to bitcoin-specific little endian format."""
30
+ # The top bit is used to indicate the sign of the number. If there
31
+ # isn't a spare bit in the bit length, add an extension byte.
32
+ have_ext = False
33
+ ext = bytearray ()
34
+ if v .bit_length () > 0 :
35
+ have_ext = (v .bit_length () & 0x07 ) == 0
36
+ ext .append (0 )
37
+
38
+ # Is the number negative?
39
+ neg = False
40
+ if v < 0 :
41
+ neg = True
42
+ v = - v
43
+
44
+ # Convert the int to bytes
45
+ v_bin = bytearray ()
46
+ bytes_len = (v .bit_length () + 7 ) // 8
47
+ for i in range (bytes_len , 0 , - 1 ):
48
+ v_bin .append ((v >> ((i - 1 ) * 8 )) & 0xff )
49
+
50
+ # Add the sign bit if necessary
51
+ if neg :
52
+ if have_ext :
53
+ ext [0 ] |= 0x80
54
+ else :
55
+ v_bin [0 ] |= 0x80
56
+
57
+ v_bytes = ext + v_bin
58
+ # Reverse bytes ordering for LE
59
+ v_bytes .reverse ()
60
+
61
+ return bytes (v_bytes )
29
62
30
63
_opcode_instances = []
31
64
class CScriptOp (int ):
You can’t perform that action at this time.
0 commit comments