mirror of
https://github.com/basicswap/basicswap.git
synced 2024-12-23 03:49:25 +00:00
Move more methods to Base class.
This commit is contained in:
parent
617006c67a
commit
9953a934a5
2 changed files with 14 additions and 13 deletions
|
@ -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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue