Add bid intent messages.

This commit is contained in:
tecnovert
2023-07-05 23:35:25 +02:00
parent 00bebfa371
commit f6fb11f452
23 changed files with 1231 additions and 633 deletions

View File

@@ -318,6 +318,27 @@ class BTCInterface(CoinInterface):
args.append('bech32')
return self.rpc_callback('getnewaddress', args)
def isValidAddress(self, address: str) -> bool:
try:
rv = self.rpc_callback('validateaddress', [address])
if rv['isvalid'] is True:
return True
except Exception as ex:
self._log.debug('validateaddress failed: {}'.format(address))
return False
def isValidAddressHash(self, address_hash: bytes) -> bool:
hash_len = len(address_hash)
if hash_len == 20:
return True
def isValidPubkey(self, pubkey: bytes) -> bool:
try:
self.verifyPubkey(pubkey)
return True
except Exception:
return False
def isAddressMine(self, address: str, or_watch_only: bool = False) -> bool:
addr_info = self.rpc_callback('getaddressinfo', [address])
if not or_watch_only:
@@ -1434,6 +1455,10 @@ class BTCInterface(CoinInterface):
tx.rehash()
return tx.serialize().hex()
def ensureFunds(self, amount):
if self.getSpendableBalance() < amount:
raise ValueError('Balance too low')
def testBTCInterface():
print('TODO: testBTCInterface')