@@ -281,6 +281,8 @@ type addSweepsRequest struct {
281281 parentBatch * dbBatch
282282}
283283
284+ // SpendDetail is a notification that is send to the user of sweepbatcher when
285+ // a batch gets the first confirmation.
284286type SpendDetail struct {
285287 // Tx is the transaction that spent the outpoint.
286288 Tx * wire.MsgTx
@@ -292,6 +294,19 @@ type SpendDetail struct {
292294 OnChainFeePortion btcutil.Amount
293295}
294296
297+ // ConfDetail is a notification that is send to the user of sweepbatcher when
298+ // a batch is fully confirmed, i.e. gets batchConfHeight confirmations.
299+ type ConfDetail struct {
300+ // TxConfirmation has data about the confirmation of the transaction.
301+ * chainntnfs.TxConfirmation
302+
303+ // OnChainFeePortion is the fee portion that was paid to get this sweep
304+ // confirmed on chain. This is the difference between the value of the
305+ // outpoint and the value of all sweeps that were included in the batch
306+ // divided by the number of sweeps.
307+ OnChainFeePortion btcutil.Amount
308+ }
309+
295310// SpendNotifier is a notifier that is used to notify the requester of a sweep
296311// that the sweep was successful.
297312type SpendNotifier struct {
@@ -303,7 +318,7 @@ type SpendNotifier struct {
303318
304319 // ConfChan is a channel where the confirmation details are received.
305320 // This channel is optional.
306- ConfChan chan <- * chainntnfs. TxConfirmation
321+ ConfChan chan <- * ConfDetail
307322
308323 // ConfErrChan is a channel where confirmation errors are received.
309324 // This channel is optional.
@@ -1185,6 +1200,7 @@ func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
11851200 case notifier .SpendChan <- spendDetail :
11861201 err := b .monitorConfAndNotify (
11871202 ctx , sweep , notifier , spendTx ,
1203+ onChainFeePortion ,
11881204 )
11891205 if err != nil {
11901206 b .writeToErrChan (
@@ -1240,7 +1256,8 @@ func (b *Batcher) monitorSpendAndNotify(ctx context.Context, sweep *sweep,
12401256// is fully confirmed and we just need to deliver the data back to the caller
12411257// though SpendNotifier.
12421258func (b * Batcher ) monitorConfAndNotify (ctx context.Context , sweep * sweep ,
1243- notifier * SpendNotifier , spendTx * wire.MsgTx ) error {
1259+ notifier * SpendNotifier , spendTx * wire.MsgTx ,
1260+ onChainFeePortion btcutil.Amount ) error {
12441261
12451262 // If confirmation notifications were not requested, stop.
12461263 if notifier .ConfChan == nil && notifier .ConfErrChan == nil {
@@ -1276,8 +1293,13 @@ func (b *Batcher) monitorConfAndNotify(ctx context.Context, sweep *sweep,
12761293 select {
12771294 case conf := <- confChan :
12781295 if notifier .ConfChan != nil {
1296+ confDetail := & ConfDetail {
1297+ TxConfirmation : conf ,
1298+ OnChainFeePortion : onChainFeePortion ,
1299+ }
1300+
12791301 select {
1280- case notifier .ConfChan <- conf :
1302+ case notifier .ConfChan <- confDetail :
12811303 case <- notifier .QuitChan :
12821304 case <- ctx .Done ():
12831305 }
0 commit comments