Move more methods to Base class.

This commit is contained in:
tecnovert 2019-11-18 23:41:48 +02:00
parent 617006c67a
commit 9953a934a5
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
2 changed files with 14 additions and 13 deletions

View file

@ -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)

View file

@ -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