Add txn 1st seen height to bid.

Format balance amount.
Start prepare script.
This commit is contained in:
tecnovert
2019-07-21 18:25:01 +02:00
parent f1efb0a317
commit 76af4a941e
12 changed files with 378 additions and 201 deletions

View File

@@ -351,6 +351,7 @@ class Bid(Base):
initiate_spend_txid = sa.Column(sa.LargeBinary)
initiate_spend_n = sa.Column(sa.Integer)
initiate_txn_height = sa.Column(sa.Integer)
initiate_txn_state = sa.Column(sa.Integer)
initiate_txn_states = sa.Column(sa.LargeBinary) # Packed states and times
@@ -364,6 +365,7 @@ class Bid(Base):
participate_spend_txid = sa.Column(sa.LargeBinary)
participate_spend_n = sa.Column(sa.Integer)
participate_txn_height = sa.Column(sa.Integer)
participate_txn_state = sa.Column(sa.Integer)
participate_txn_states = sa.Column(sa.LargeBinary) # Packed states and times
@@ -371,6 +373,8 @@ class Bid(Base):
state_time = sa.Column(sa.BigInteger) # timestamp of last state change
states = sa.Column(sa.LargeBinary) # Packed states and times
state_note = sa.Column(sa.String)
def setITXState(self, new_state):
self.initiate_txn_state = new_state
if self.initiate_txn_states is None:
@@ -1438,6 +1442,8 @@ class BasicSwap():
self.coin_clients[coin_type]['last_height_checked'] = tx_height
self.log.debug('Rewind checking of %s chain to height %d', chain_name, tx_height)
return tx_height
def addParticipateTxn(self, bid_id, bid, coin_type, txid_hex, vout, tx_height):
bid.participate_txid = bytes.fromhex(txid_hex)
bid.participate_txn_n = vout
@@ -1447,7 +1453,7 @@ class BasicSwap():
self.log.debug('Watching %s chain for spend of output %s %d', chain_name, txid_hex, vout)
# TODO: Check connection type
self.setLastHeightChecked(coin_type, tx_height)
bid.participate_txn_height = self.setLastHeightChecked(coin_type, tx_height)
self.log.debug('Adding watched output %s bid %s tx %s type %s', coin_type, bid_id.hex(), txid_hex, BidStates.SWAP_PARTICIPATING)
self.coin_clients[coin_type]['watched_outputs'].append((bid_id, txid_hex, vout, BidStates.SWAP_PARTICIPATING))
@@ -1556,12 +1562,12 @@ class BasicSwap():
if bid.initiate_txn_n is None:
bid.initiate_txn_n = index
# Start checking for spends of initiate_txn before fully confirmed
self.setLastHeightChecked(coin_from, tx_height)
bid.initiate_txn_height = self.setLastHeightChecked(coin_from, tx_height)
self.log.debug('Adding watched output %s bid %s tx %s type %s', coin_from, bid_id.hex(), initiate_txnid_hex, BidStates.SWAP_INITIATED)
self.coin_clients[coin_from]['watched_outputs'].append((bid_id, initiate_txnid_hex, bid.initiate_txn_n, BidStates.SWAP_INITIATED))
if bid.initiate_txn_state is None or bid.initiate_txn_state < TxStates.TX_SENT:
bid.setITXState(TxStates.TX_SENT)
save_bid = True
save_bid = True
if bid.initiate_txn_conf >= self.coin_clients[coin_from]['blocks_confirmed']:
self.initiateTxnConfirmed(bid_id, bid, offer)
@@ -2112,7 +2118,7 @@ class BasicSwap():
'deposit_address': self.getCachedAddressForCoin(coin),
'name': chainparams[coin]['name'].capitalize(),
'blocks': blockchaininfo['blocks'],
'balance': walletinfo.get('total_balance', walletinfo['balance']),
'balance': format8(walletinfo.get('total_balance', walletinfo['balance']) * COIN),
'synced': '{0:.2f}'.format(round(blockchaininfo['verificationprogress'], 2)),
}
return rv

View File

@@ -9,16 +9,16 @@ import os
DATADIRS = os.path.expanduser(os.getenv('DATADIRS', '/tmp/basicswap'))
PARTICL_BINDIR = os.path.expanduser(os.getenv('PARTICL_BINDIR', ''))
PARTICLD = os.getenv('PARTICLD', 'particld')
PARTICL_CLI = os.getenv('PARTICL_CLI', 'particl-cli')
PARTICL_TX = os.getenv('PARTICL_TX', 'particl-tx')
PARTICLD = os.getenv('PARTICLD', 'particld' + ('.exe' if os.name == 'nt' else ''))
PARTICL_CLI = os.getenv('PARTICL_CLI', 'particl-cli' + ('.exe' if os.name == 'nt' else ''))
PARTICL_TX = os.getenv('PARTICL_TX', 'particl-tx' + ('.exe' if os.name == 'nt' else ''))
BITCOIN_BINDIR = os.path.expanduser(os.getenv('BITCOIN_BINDIR', ''))
BITCOIND = os.getenv('BITCOIND', 'bitcoind')
BITCOIN_CLI = os.getenv('BITCOIN_CLI', 'bitcoin-cli')
BITCOIN_TX = os.getenv('BITCOIN_TX', 'bitcoin-tx')
BITCOIND = os.getenv('BITCOIND', 'bitcoind' + ('.exe' if os.name == 'nt' else ''))
BITCOIN_CLI = os.getenv('BITCOIN_CLI', 'bitcoin-cli' + ('.exe' if os.name == 'nt' else ''))
BITCOIN_TX = os.getenv('BITCOIN_TX', 'bitcoin-tx' + ('.exe' if os.name == 'nt' else ''))
LITECOIN_BINDIR = os.path.expanduser(os.getenv('LITECOIN_BINDIR', ''))
LITECOIND = os.getenv('LITECOIND', 'litecoind')
LITECOIN_CLI = os.getenv('LITECOIN_CLI', 'litecoin-cli')
LITECOIN_TX = os.getenv('LITECOIN_TX', 'litecoin-tx')
LITECOIND = os.getenv('LITECOIND', 'litecoind' + ('.exe' if os.name == 'nt' else ''))
LITECOIN_CLI = os.getenv('LITECOIN_CLI', 'litecoin-cli' + ('.exe' if os.name == 'nt' else ''))
LITECOIN_TX = os.getenv('LITECOIN_TX', 'litecoin-tx' + ('.exe' if os.name == 'nt' else ''))

View File

@@ -130,7 +130,7 @@ class HttpHandler(BaseHTTPRequestHandler):
cid = str(int(k))
content += '<h4>' + w['name'] + '</h4>' \
+ '<table>' \
+ '<tr><td>Balance:</td><td>' + str(w['balance']) + '</td></tr>' \
+ '<tr><td>Balance:</td><td>' + w['balance'] + '</td></tr>' \
+ '<tr><td>Blocks:</td><td>' + str(w['blocks']) + '</td></tr>' \
+ '<tr><td>Synced:</td><td>' + str(w['synced']) + '</td></tr>' \
+ '<tr><td><input type="submit" name="newaddr_' + cid + '" value="Deposit Address"></td><td>' + str(w['deposit_address']) + '</td></tr>' \