mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-02 03:01:32 +02:00
sweep: remove dead code and add better logging
This commit is contained in:
parent
50bc191feb
commit
121116cff7
@ -211,7 +211,7 @@ func (m *MempoolNotifier) findRelevantInputs(tx *btcutil.Tx) (inputsWithTx,
|
|||||||
|
|
||||||
// If found, save it to watchedInputs to notify the
|
// If found, save it to watchedInputs to notify the
|
||||||
// subscriber later.
|
// subscriber later.
|
||||||
Log.Infof("Found input %s, spent in %s", op, txid)
|
Log.Debugf("Found input %s, spent in %s", op, txid)
|
||||||
|
|
||||||
// Construct the spend details.
|
// Construct the spend details.
|
||||||
details := &SpendDetail{
|
details := &SpendDetail{
|
||||||
|
@ -972,7 +972,6 @@ func (t *TxPublisher) processRecords() {
|
|||||||
// For records that are confirmed, we'll notify the caller about this
|
// For records that are confirmed, we'll notify the caller about this
|
||||||
// result.
|
// result.
|
||||||
for _, r := range confirmedRecords {
|
for _, r := range confirmedRecords {
|
||||||
log.Debugf("Tx=%v is confirmed", r.tx.TxHash())
|
|
||||||
t.wg.Add(1)
|
t.wg.Add(1)
|
||||||
go t.handleTxConfirmed(r)
|
go t.handleTxConfirmed(r)
|
||||||
}
|
}
|
||||||
@ -982,7 +981,6 @@ func (t *TxPublisher) processRecords() {
|
|||||||
|
|
||||||
// For records that are not confirmed, we perform a fee bump if needed.
|
// For records that are not confirmed, we perform a fee bump if needed.
|
||||||
for _, r := range feeBumpRecords {
|
for _, r := range feeBumpRecords {
|
||||||
log.Debugf("Attempting to fee bump Tx=%v", r.tx.TxHash())
|
|
||||||
t.wg.Add(1)
|
t.wg.Add(1)
|
||||||
go t.handleFeeBumpTx(r, currentHeight)
|
go t.handleFeeBumpTx(r, currentHeight)
|
||||||
}
|
}
|
||||||
@ -990,8 +988,6 @@ func (t *TxPublisher) processRecords() {
|
|||||||
// For records that are failed, we'll notify the caller about this
|
// For records that are failed, we'll notify the caller about this
|
||||||
// result.
|
// result.
|
||||||
for _, r := range failedRecords {
|
for _, r := range failedRecords {
|
||||||
log.Debugf("Tx=%v has inputs been spent by a third party, "+
|
|
||||||
"failing it now", r.tx.TxHash())
|
|
||||||
t.wg.Add(1)
|
t.wg.Add(1)
|
||||||
go t.handleThirdPartySpent(r)
|
go t.handleThirdPartySpent(r)
|
||||||
}
|
}
|
||||||
@ -1004,6 +1000,8 @@ func (t *TxPublisher) processRecords() {
|
|||||||
func (t *TxPublisher) handleTxConfirmed(r *monitorRecord) {
|
func (t *TxPublisher) handleTxConfirmed(r *monitorRecord) {
|
||||||
defer t.wg.Done()
|
defer t.wg.Done()
|
||||||
|
|
||||||
|
log.Debugf("Record %v is spent in tx=%v", r.requestID, r.tx.TxHash())
|
||||||
|
|
||||||
// Create a result that will be sent to the resultChan which is
|
// Create a result that will be sent to the resultChan which is
|
||||||
// listened by the caller.
|
// listened by the caller.
|
||||||
result := &BumpResult{
|
result := &BumpResult{
|
||||||
@ -1113,6 +1111,9 @@ func (t *TxPublisher) handleInitialBroadcast(r *monitorRecord) {
|
|||||||
func (t *TxPublisher) handleFeeBumpTx(r *monitorRecord, currentHeight int32) {
|
func (t *TxPublisher) handleFeeBumpTx(r *monitorRecord, currentHeight int32) {
|
||||||
defer t.wg.Done()
|
defer t.wg.Done()
|
||||||
|
|
||||||
|
log.Debugf("Attempting to fee bump tx=%v in record %v", r.tx.TxHash(),
|
||||||
|
r.requestID)
|
||||||
|
|
||||||
oldTxid := r.tx.TxHash()
|
oldTxid := r.tx.TxHash()
|
||||||
|
|
||||||
// Get the current conf target for this record.
|
// Get the current conf target for this record.
|
||||||
@ -1158,6 +1159,10 @@ func (t *TxPublisher) handleFeeBumpTx(r *monitorRecord, currentHeight int32) {
|
|||||||
func (t *TxPublisher) handleThirdPartySpent(r *monitorRecord) {
|
func (t *TxPublisher) handleThirdPartySpent(r *monitorRecord) {
|
||||||
defer t.wg.Done()
|
defer t.wg.Done()
|
||||||
|
|
||||||
|
log.Debugf("Record %v has inputs spent by a tx unknown to the fee "+
|
||||||
|
"bumper, failing it now:\n%v", r.requestID,
|
||||||
|
inputTypeSummary(r.req.Inputs))
|
||||||
|
|
||||||
// Create a result that will be sent to the resultChan which is
|
// Create a result that will be sent to the resultChan which is
|
||||||
// listened by the caller.
|
// listened by the caller.
|
||||||
result := &BumpResult{
|
result := &BumpResult{
|
||||||
@ -1272,17 +1277,6 @@ func (t *TxPublisher) createAndPublishTx(
|
|||||||
return fn.Some(*result)
|
return fn.Some(*result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// isConfirmed checks the btcwallet to see whether the tx is confirmed.
|
|
||||||
func (t *TxPublisher) isConfirmed(txid chainhash.Hash) bool {
|
|
||||||
details, err := t.cfg.Wallet.GetTransactionDetails(&txid)
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("Failed to get tx details for %v: %v", txid, err)
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return details.NumConfirmations > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// isThirdPartySpent checks whether the inputs of the tx has already been spent
|
// isThirdPartySpent checks whether the inputs of the tx has already been spent
|
||||||
// by a third party. When a tx is not confirmed, yet its inputs has been spent,
|
// by a third party. When a tx is not confirmed, yet its inputs has been spent,
|
||||||
// then it must be spent by a different tx other than the sweeping tx here.
|
// then it must be spent by a different tx other than the sweeping tx here.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user