Skip to content
This repository has been archived by the owner on May 13, 2022. It is now read-only.

Commit

Permalink
Fix bug in --rpcwallet option; BitcoinCoreWallet.get_key_from_addr no…
Browse files Browse the repository at this point in the history
…w returns hex, not wif privkey.

Remove legacy unused main() in joinmarket/maker.py
  • Loading branch information
AdamISZ committed Sep 14, 2016
1 parent 9c954d7 commit 6a86338
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 39 deletions.
31 changes: 0 additions & 31 deletions joinmarket/maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,34 +492,3 @@ def on_tx_confirmed(self, cjorder, confirmations, txid):
'utxo': txid + ':' + str(i)}
to_announce.append(neworder)
return [], to_announce


def main():
from socket import gethostname
nickname = 'cj-maker-' + btc.sha256(gethostname())[:6]
import sys
seed = sys.argv[
1
] # btc.sha256('dont use brainwallets except for holding testnet coins')

load_program_config()
wallet = Wallet(seed, max_mix_depth=5)
jm_single().bc_interface.sync_wallet(wallet)

irc = IRCMessageChannel(nickname)
maker = Maker(irc, wallet)
try:
print('connecting to irc')
irc.run()
except:
log.debug('CRASHING, DUMPING EVERYTHING')
log.debug('wallet seed = ' + seed)
debug_dump_object(wallet, ['addr_cache'])
debug_dump_object(maker)
import traceback
traceback.print_exc()


if __name__ == "__main__":
main()
print('done')
3 changes: 2 additions & 1 deletion joinmarket/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,8 @@ def __init__(self, fromaccount):

def get_key_from_addr(self, addr):
self.ensure_wallet_unlocked()
return jm_single().bc_interface.rpc('dumpprivkey', [addr])
wifkey = jm_single().bc_interface.rpc('dumpprivkey', [addr])
return btc.from_wif_privkey(wifkey, vbyte=get_p2pk_vbyte())

def get_utxos_by_mixdepth(self):
unspent_list = jm_single().bc_interface.rpc('listunspent', [])
Expand Down
21 changes: 14 additions & 7 deletions test/test_regtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import shutil
import pytest
import time
from joinmarket import Taker, load_program_config, IRCMessageChannel
from joinmarket import (Taker, load_program_config, IRCMessageChannel,
BitcoinCoreWallet)
from joinmarket import validate_address, jm_single, get_irc_mchannels
from joinmarket import random_nick, get_p2pk_vbyte, MessageChannelCollection
from joinmarket import get_log, choose_sweep_orders, choose_orders, \
Expand All @@ -25,27 +26,30 @@
#yg_cmd = 'yg-pe.py'

@pytest.mark.parametrize(
"num_ygs, wallet_structures, mean_amt, mixdepth, sending_amt, ygcfs, fails, donate",
"num_ygs, wallet_structures, mean_amt, mixdepth, sending_amt, ygcfs, fails, donate, rpcwallet",
[
#Some tests are commented out to keep build test time reasonable.
#Note that rpcwallet tests cannot be amt=0 and must have mixdepth=0
# basic 1sp 2yg.
#(4, [[1, 0, 0, 0, 0]] * 5, 10, 0, 100000000, None, None, 0.5),
(4, [[1, 0, 0, 0, 0]] * 5, 10, 0, 100000000, None, None, None),
#(4, [[1, 0, 0, 0, 0]] * 5, 10, 0, 100000000, None, None, None, False),
(4, [[1, 0, 0, 0, 0]] * 5, 10, 0, 100000000, None, None, None, True),
#Testing different message channel collections. (Needs manual config at
#the moment - create different config files for each yg).
#(4, [[1, 0, 0, 0, 0]] * 5, 10, 0, 100000000, ["j2.cfg", "j3.cfg",
# "j4.cfg", "j5.cfg"], None),
# 1sp 3yg, 2 mixdepths - testing different failure times to
#see if recovery works.
#(5, [[1, 2, 0, 0, 0]] * 6, 4, 1, 1234500, None, None),
(4, [[1, 2, 0, 0, 0]] * 5, 4, 1, 1234500, None, ('break',0,6), None),
(4, [[1, 2, 0, 0, 0]] * 5, 4, 1, 1234500, None, ('break',0,6), None, False),
#(4, [[1, 2, 0, 0, 0]] * 5, 4, 0, 1234500, None, ('break',0,6), None, True),
#(5, [[1, 2, 0, 0, 0]] * 6, 4, 1, 1234500, None, ('shutdown',0,12)),
#(5, [[1, 2, 0, 0, 0]] * 6, 4, 1, 1234500, None, ('break',1, 6)),
# 1sp 6yg, 4 mixdepths, sweep from depth 0 (test large number of makers)
(8, [[1, 3, 0, 0, 0]] * 9, 4, 0, 0, None, None, None),
(8, [[1, 3, 0, 0, 0]] * 9, 4, 0, 0, None, None, None, False),
])
def test_sendpayment(setup_regtest, num_ygs, wallet_structures, mean_amt,
mixdepth, sending_amt, ygcfs, fails, donate):
mixdepth, sending_amt, ygcfs, fails, donate, rpcwallet):
"""Test of sendpayment code, with yield generators in background.
"""
log = get_log()
Expand All @@ -58,7 +62,10 @@ def test_sendpayment(setup_regtest, num_ygs, wallet_structures, mean_amt,
wallet_structures=wallet_structures,
mean_amt=mean_amt)
#the sendpayment bot uses the last wallet in the list
wallet = wallets[makercount]['wallet']
if not rpcwallet:
wallet = wallets[makercount]['wallet']
else:
wallet = BitcoinCoreWallet(fromaccount="")

yigen_procs = []
if ygcfs:
Expand Down

0 comments on commit 6a86338

Please sign in to comment.