Store channel closing date
This commit is contained in:
		
							parent
							
								
									51a8655101
								
							
						
					
					
						commit
						459dee69d4
					
				@ -215,6 +215,7 @@ class DatabaseMigration {
 | 
			
		||||
      created datetime DEFAULT NULL,
 | 
			
		||||
      status int(11) NOT NULL DEFAULT 0,
 | 
			
		||||
      closing_transaction_id varchar(64) DEFAULT NULL,
 | 
			
		||||
      closing_date datetime DEFAULT NULL,
 | 
			
		||||
      closing_reason int(11) DEFAULT NULL,
 | 
			
		||||
      node1_public_key varchar(66) NOT NULL,
 | 
			
		||||
      node1_base_fee_mtokens bigint(20) unsigned DEFAULT NULL,
 | 
			
		||||
 | 
			
		||||
@ -119,7 +119,8 @@ class NodeSyncService {
 | 
			
		||||
        const spendingTx = await bitcoinApi.$getOutspend(channel.transaction_id, channel.transaction_vout);
 | 
			
		||||
        if (spendingTx.spent === true && spendingTx.status?.confirmed === true) {
 | 
			
		||||
          logger.debug('Marking channel: ' + channel.id + ' as closed.');
 | 
			
		||||
          await DB.query(`UPDATE channels SET status = 2 WHERE id = ?`, [channel.id]);
 | 
			
		||||
          await DB.query(`UPDATE channels SET status = 2, closing_date = FROM_UNIXTIME(?) WHERE id = ?`,
 | 
			
		||||
            [spendingTx.status.block_time, channel.id]);
 | 
			
		||||
          if (spendingTx.txid && !channel.closing_transaction_id) {
 | 
			
		||||
            await DB.query(`UPDATE channels SET closing_transaction_id = ? WHERE id = ?`, [spendingTx.txid, channel.id]);
 | 
			
		||||
          }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user