Host-customized fork of https://github.com/tecnovert/basicswap/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.5 KiB
43 lines
1.5 KiB
4 years ago
|
#!/usr/bin/env python
|
||
|
# -*- coding: utf-8 -*-
|
||
|
|
||
3 years ago
|
# Copyright (c) 2020-2022 tecnovert
|
||
4 years ago
|
# Distributed under the MIT software license, see the accompanying
|
||
|
# file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
||
|
|
||
2 years ago
|
from .btc import BTCInterface
|
||
|
from basicswap.chainparams import Coins
|
||
|
from basicswap.util import (
|
||
3 years ago
|
make_int,
|
||
|
)
|
||
4 years ago
|
|
||
4 years ago
|
|
||
4 years ago
|
class NMCInterface(BTCInterface):
|
||
4 years ago
|
@staticmethod
|
||
|
def coin_type():
|
||
|
return Coins.NMC
|
||
3 years ago
|
|
||
|
def getLockTxHeight(self, txid, dest_address, bid_amount, rescan_from, find_index=False):
|
||
3 years ago
|
self._log.debug('[rm] scantxoutset start') # scantxoutset is slow
|
||
|
ro = self.rpc_callback('scantxoutset', ['start', ['addr({})'.format(dest_address)]]) # TODO: Use combo(address) where possible
|
||
|
self._log.debug('[rm] scantxoutset end')
|
||
|
return_txid = True if txid is None else False
|
||
|
for o in ro['unspents']:
|
||
|
if txid and o['txid'] != txid.hex():
|
||
|
continue
|
||
|
# Verify amount
|
||
|
if make_int(o['amount']) != int(bid_amount):
|
||
|
self._log.warning('Found output to lock tx address of incorrect value: %s, %s', str(o['amount']), o['txid'])
|
||
|
continue
|
||
|
|
||
|
rv = {
|
||
|
'depth': 0,
|
||
|
'height': o['height']}
|
||
|
if o['height'] > 0:
|
||
|
rv['depth'] = ro['height'] - o['height']
|
||
|
if find_index:
|
||
|
rv['index'] = o['vout']
|
||
|
if return_txid:
|
||
|
rv['txid'] = o['txid']
|
||
|
return rv
|