Browse Source

add JMBaseCodeMixin.get_wif_path

add-joinmarket
zebra-lucky 1 year ago
parent
commit
f6aa72b9ef
  1. 10
      electrum/plugins/joinmarket/jm_base_code.py
  2. 5
      electrum/plugins/joinmarket/jmclient/wallet_utils.py
  3. 1
      electrum/plugins/joinmarket/notes.txt
  4. 7
      electrum/plugins/joinmarket/tests/test_jm_base_code.py

10
electrum/plugins/joinmarket/jm_base_code.py

@ -12,7 +12,7 @@ import electrum_ecc as ecc
from electrum.bip32 import convert_bip32_intpath_to_strpath
from electrum.bitcoin import (script_to_scripthash, address_to_script,
construct_script, opcodes)
construct_script, opcodes, serialize_privkey)
from electrum.crypto import sha256
from electrum.descriptor import get_singlesig_descriptor_from_legacy_leaf
from electrum.transaction import (get_address_from_output_script,
@ -345,6 +345,14 @@ class JMBaseCodeMixin:
privk, _ = w.keystore.get_private_key(path, None)
return privk
# jmclient/wallet.py BaseWallet.get_wif_path
def get_wif_path(self, path, password):
w = self.wallet
addr = self.get_address_from_path(path)
privk, compressed = w.keystore.get_private_key(path, password)
txin_type = w.get_txin_type(addr)
return serialize_privkey(privk, compressed, txin_type)
# jmclient/wallet.py BaseWallet/BIP32Wallet get_script_from_path
def get_script_from_path(self, path) -> bytes:
addr = self.get_address_from_path(path)

5
electrum/plugins/joinmarket/jmclient/wallet_utils.py

@ -351,7 +351,7 @@ def get_utxo_status_string(utxos, utxos_enabled, path):
def wallet_display(jmman, showprivkey, displayall=False,
serialized=True, summarized=False, mixdepth=None,
jsonified=False):
jsonified=False, password=None):
"""build the walletview object,
then return its serialization directly if serialized,
else return the WalletView object.
@ -415,8 +415,7 @@ def wallet_display(jmman, showprivkey, displayall=False,
balance, status = get_addr_status(
path, utxos[m], utxos_enabled[m], is_new, address_type)
if showprivkey:
# privkey = jmman.get_wif_path(path) FIXME no get_wif_path
privkey = '' # FIXME
privkey = jmman.jmw.get_wif_path(path, password)
else:
privkey = ''
if (displayall or balance > 0 or

1
electrum/plugins/joinmarket/notes.txt

@ -1,7 +1,6 @@
-------------------------------------------------------------------------------
plugin:
- покращення покриття тестами
- jm_base_code.py: add get_wif_path (need password if wallet/ks encrypted)
- потрібно якось документувати
- qml gui
- jm_qt_obwatch: advanced sorting by columns, filter by text

7
electrum/plugins/joinmarket/tests/test_jm_base_code.py

@ -245,6 +245,13 @@ class JMBaseCodeMixinTestCase(JMTestCase):
assert await jmw.make_keypairs_cache(None, None)
assert jmw.get_key_from_addr(addr) == keypair[1]
async def test_get_wif_path(self):
jmw = self.jmw
w = jmw.wallet
idx = w.get_address_index('tb1qpjkqrhz3kxsg93c5cw2axhdy39wqy36u9ygzdk')
wif = 'p2wpkh:cUFGYhBPap7YEr4yq1BX1iVGHqmYK9udFnXmQz2LxRKBv11PXyf3'
assert jmw.get_wif_path(idx, None) == wif
async def test_get_script_from_path(self):
jmw = self.jmw
w = jmw.wallet

Loading…
Cancel
Save