From 9953a934a54325f103617ed3d3660b4498c0301e Mon Sep 17 00:00:00 2001 From: tecnovert Date: Mon, 18 Nov 2019 23:41:48 +0200 Subject: [PATCH] Move more methods to Base class. --- basicswap/base.py | 14 ++++++++++++++ basicswap/basicswap.py | 13 ------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/basicswap/base.py b/basicswap/base.py index 198b572..beb70b5 100644 --- a/basicswap/base.py +++ b/basicswap/base.py @@ -10,12 +10,14 @@ import logging import subprocess import basicswap.config as cfg +import basicswap.segwit_addr as segwit_addr from .chainparams import ( chainparams, Coins, ) from .util import ( + pubkeyToAddress, callrpc, ) @@ -85,6 +87,18 @@ class BaseApp: ticker = 'rt' + ticker return ticker + def encodeSegwitP2WSH(self, coin_type, p2wsh): + return segwit_addr.encode(chainparams[coin_type][self.chain]['hrp'], 0, p2wsh[2:]) + + def encodeSegwit(self, coin_type, raw): + return segwit_addr.encode(chainparams[coin_type][self.chain]['hrp'], 0, raw) + + def decodeSegwit(self, coin_type, addr): + return bytes(segwit_addr.decode(chainparams[coin_type][self.chain]['hrp'], addr)[1]) + + def getScriptAddress(self, coin_type, script): + return pubkeyToAddress(chainparams[coin_type][self.chain]['script_address'], script) + def callrpc(self, method, params=[], wallet=None): return callrpc(self.coin_clients[Coins.PART]['rpcport'], self.coin_clients[Coins.PART]['rpcauth'], method, params, wallet) diff --git a/basicswap/basicswap.py b/basicswap/basicswap.py index 58b0209..e0b160f 100644 --- a/basicswap/basicswap.py +++ b/basicswap/basicswap.py @@ -61,7 +61,6 @@ from .db import ( from .explorers import ExplorerInsight, ExplorerBitAps, ExplorerChainz import basicswap.config as cfg -import basicswap.segwit_addr as segwit_addr from .base import BaseApp @@ -1231,18 +1230,6 @@ class BasicSwap(BaseApp): session.remove() self.mxDB.release() - def encodeSegwitP2WSH(self, coin_type, p2wsh): - return segwit_addr.encode(chainparams[coin_type][self.chain]['hrp'], 0, p2wsh[2:]) - - def encodeSegwit(self, coin_type, raw): - return segwit_addr.encode(chainparams[coin_type][self.chain]['hrp'], 0, raw) - - def decodeSegwit(self, coin_type, addr): - return bytes(segwit_addr.decode(chainparams[coin_type][self.chain]['hrp'], addr)[1]) - - def getScriptAddress(self, coin_type, script): - return pubkeyToAddress(chainparams[coin_type][self.chain]['script_address'], script) - def setBidError(self, bif_id, bid, error_str): bid.setState(BidStates.BID_ERROR) bid.state_note = 'error msg: ' + error_str