tln: avoid code duplication - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 4515c859c4c2e62f1c6ca4a51d4494afde870f2c DIR parent fe973a5137ecb1ed9a8b63e042363b0c7792edef HTML Author: Janus <ysangkok@gmail.com> Date: Thu, 28 Jun 2018 16:04:25 +0200 ln: avoid code duplication Diffstat: M lib/lnutil.py | 4 ++-- M lib/tests/test_lnutil.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) --- DIR diff --git a/lib/lnutil.py b/lib/lnutil.py t@@ -3,7 +3,7 @@ from .crypto import sha256 import json from collections import namedtuple from .transaction import Transaction -from .ecc import CURVE_ORDER, generator, sig_string_from_der_sig, ECPubkey, string_to_number +from .ecc import CURVE_ORDER, sig_string_from_der_sig, ECPubkey, string_to_number from . import ecc, bitcoin, crypto, transaction from .transaction import opcodes from .bitcoin import push_script t@@ -86,7 +86,7 @@ def derive_pubkey(basepoint, per_commitment_point): def derive_privkey(secret, per_commitment_point): assert type(secret) is int - basepoint = (ecc.generator() * secret).get_public_key_bytes() + basepoint = secret_to_pubkey(secret) basepoint = secret + ecc.string_to_number(sha256(per_commitment_point + basepoint)) basepoint %= CURVE_ORDER return basepoint DIR diff --git a/lib/tests/test_lnutil.py b/lib/tests/test_lnutil.py t@@ -1,6 +1,6 @@ import unittest import json -from lib import bitcoin, ecc +from lib import bitcoin from lib.lnutil import RevocationStore, get_per_commitment_secret_from_seed, make_offered_htlc, make_received_htlc, make_commitment, make_htlc_tx_witness, make_htlc_tx_output, make_htlc_tx_inputs, secret_to_pubkey, derive_blinded_pubkey, derive_privkey, derive_pubkey, make_htlc_tx from lib.util import bh2u, bfh t@@ -445,7 +445,7 @@ class TestLNUtil(unittest.TestCase): # actual commitment transaction fee = 0 per_commitment_secret = 0x1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100 - per_commitment_point = (ecc.generator() * per_commitment_secret).get_public_key_bytes() + per_commitment_point = secret_to_pubkey(per_commitment_secret) remote_htlcpubkey = remotepubkey local_htlcpubkey = localpubkey