Skip to content

Commit f9ec1c9

Browse files
committed
Make bitcoin.core.bignum internal use
May be replaced, as was done in Bitcoin Core [ yapified by gitreformat (github/ghtdak) on Mon Nov 30 21:11:37 2015 ]
1 parent c1e7797 commit f9ec1c9

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

README

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ consensus critical and non-consensus-critical.
2626

2727
bitcoin.core - Basic core definitions, datastructures, and
2828
(context-independent) validation
29-
bitcoin.core.bignum - Bignum handling
3029
bitcoin.core.key - ECC pubkeys
3130
bitcoin.core.script - Scripts and opcodes
3231
bitcoin.core.scripteval - Script evaluation/verification
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
# No part of python-bitcoinlib, including this file, may be copied, modified,
99
# propagated, or distributed except according to the terms contained in the
1010
# LICENSE file.
11-
"""Bignum routines"""
11+
12+
# Bignum routines
13+
#
14+
# Internally used for script evaluation; not to be used externally.
1215

1316
from __future__ import absolute_import, division, print_function, unicode_literals
1417

bitcoin/core/script.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import struct
2929

3030
import bitcoin.core
31-
import bitcoin.core.bignum
31+
import bitcoin.core._bignum
3232

3333
MAX_SCRIPT_SIZE = 10000
3434
MAX_SCRIPT_ELEMENT_SIZE = 520
@@ -527,8 +527,8 @@ def __coerce_instance(cls, other):
527527
elif other == -1:
528528
other = bytes(_bchr(OP_1NEGATE))
529529
else:
530-
other = CScriptOp.encode_op_pushdata(bitcoin.core.bignum.bn2vch(
531-
other))
530+
other = CScriptOp.encode_op_pushdata(
531+
bitcoin.core._bignum.bn2vch(other))
532532
elif isinstance(other, (bytes, bytearray)):
533533
other = CScriptOp.encode_op_pushdata(other)
534534
return other

bitcoin/core/scripteval.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import hashlib
2828

2929
import bitcoin.core
30+
import bitcoin.core._bignum
3031
import bitcoin.core.key
3132
import bitcoin.core.serialize
3233

@@ -113,7 +114,7 @@ def __init__(self, opcode, **kwargs):
113114

114115

115116
def _CastToBigNum(s, err_raiser):
116-
v = bitcoin.core.bignum.vch2bn(s)
117+
v = bitcoin.core._bignum.vch2bn(s)
117118
if len(s) > MAX_NUM_SIZE:
118119
raise err_raiser(EvalScriptError, 'CastToBigNum() : overflow')
119120
return v
@@ -252,7 +253,7 @@ def _UnaryOp(opcode, stack, err_raiser):
252253
raise AssertionError(
253254
"Unknown unary opcode encountered; this should not happen")
254255

255-
stack.append(bitcoin.core.bignum.bn2vch(bn))
256+
stack.append(bitcoin.core._bignum.bn2vch(bn))
256257

257258
# OP_LSHIFT and OP_RSHIFT are *not* included in this list as they are disabled
258259
_ISA_BINOP = {
@@ -340,7 +341,7 @@ def _BinOp(opcode, stack, err_raiser):
340341

341342
stack.pop()
342343
stack.pop()
343-
stack.append(bitcoin.core.bignum.bn2vch(bn))
344+
stack.append(bitcoin.core._bignum.bn2vch(bn))
344345

345346

346347
def _CheckExec(vfExec):
@@ -419,7 +420,7 @@ def check_args(n):
419420

420421
if sop == OP_1NEGATE or ((sop >= OP_1) and (sop <= OP_16)):
421422
v = sop - (OP_1 - 1)
422-
stack.append(bitcoin.core.bignum.bn2vch(v))
423+
stack.append(bitcoin.core._bignum.bn2vch(v))
423424

424425
elif sop in _ISA_BINOP:
425426
_BinOp(sop, stack, err_raiser)
@@ -511,7 +512,7 @@ def check_args(n):
511512

512513
elif sop == OP_DEPTH:
513514
bn = len(stack)
514-
stack.append(bitcoin.core.bignum.bn2vch(bn))
515+
stack.append(bitcoin.core._bignum.bn2vch(bn))
515516

516517
elif sop == OP_DROP:
517518
check_args(1)
@@ -631,7 +632,7 @@ def check_args(n):
631632
elif sop == OP_SIZE:
632633
check_args(1)
633634
bn = len(stack[-1])
634-
stack.append(bitcoin.core.bignum.bn2vch(bn))
635+
stack.append(bitcoin.core._bignum.bn2vch(bn))
635636

636637
elif sop == OP_SHA1:
637638
check_args(1)

0 commit comments

Comments
 (0)