mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-22 06:52:36 +01:00
[tests] remove bn_bytes() function
It is one line and is called in one place.
This commit is contained in:
parent
a760aa14a9
commit
3b9b38579c
1 changed files with 2 additions and 7 deletions
|
@ -9,17 +9,12 @@ endian format.
|
||||||
|
|
||||||
This file is copied from python-bitcoinlib.
|
This file is copied from python-bitcoinlib.
|
||||||
"""
|
"""
|
||||||
def bn_bytes(v):
|
|
||||||
"""Return number of bytes in integer representation of v."""
|
|
||||||
return (v.bit_length() + 7) // 8
|
|
||||||
|
|
||||||
def bn2bin(v):
|
def bn2bin(v):
|
||||||
"""Convert a number to a byte array."""
|
"""Convert a number to a byte array."""
|
||||||
s = bytearray()
|
s = bytearray()
|
||||||
i = bn_bytes(v)
|
bytes_len = (v.bit_length() + 7) // 8
|
||||||
while i > 0:
|
for i in range(bytes_len, 0, -1):
|
||||||
s.append((v >> ((i - 1) * 8)) & 0xff)
|
s.append((v >> ((i - 1) * 8)) & 0xff)
|
||||||
i -= 1
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
def bn2mpi(v):
|
def bn2mpi(v):
|
||||||
|
|
Loading…
Add table
Reference in a new issue