Skip to content

Commit 3197525

Browse files
Roasbeefguggero
authored andcommitted
contractcourt: update GenSweepScript to return internal key
For the upcoming aux sweeper integration, the internal key is needed for the call backs.
1 parent 29209d5 commit 3197525

File tree

3 files changed

+19
-22
lines changed

3 files changed

+19
-22
lines changed

contractcourt/breach_arbitrator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ type BreachConfig struct {
149149
Estimator chainfee.Estimator
150150

151151
// GenSweepScript generates the receiving scripts for swept outputs.
152-
GenSweepScript func() ([]byte, error)
152+
GenSweepScript func() fn.Result[lnwallet.AddrWithKey]
153153

154154
// Notifier provides a publish/subscribe interface for event driven
155155
// notifications regarding the confirmation of txids.
@@ -1517,7 +1517,7 @@ func (b *BreachArbitrator) sweepSpendableOutputsTxn(txWeight lntypes.WeightUnit,
15171517
// sweep the funds to.
15181518
// TODO(roasbeef): possibly create many outputs to minimize change in
15191519
// the future?
1520-
pkScript, err := b.cfg.GenSweepScript()
1520+
pkScript, err := b.cfg.GenSweepScript().Unpack()
15211521
if err != nil {
15221522
return nil, err
15231523
}
@@ -1545,7 +1545,7 @@ func (b *BreachArbitrator) sweepSpendableOutputsTxn(txWeight lntypes.WeightUnit,
15451545

15461546
// We begin by adding the output to which our funds will be deposited.
15471547
txn.AddTxOut(&wire.TxOut{
1548-
PkScript: pkScript,
1548+
PkScript: pkScript.DeliveryAddress,
15491549
Value: sweepAmt,
15501550
})
15511551

contractcourt/breach_arbitrator_test.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2131,15 +2131,19 @@ func createTestArbiter(t *testing.T, contractBreaches chan *ContractBreachEvent,
21312131
// Assemble our test arbiter.
21322132
notifier := mock.MakeMockSpendNotifier()
21332133
ba := NewBreachArbitrator(&BreachConfig{
2134-
CloseLink: func(_ *wire.OutPoint, _ ChannelCloseType) {},
2135-
DB: db.ChannelStateDB(),
2136-
Estimator: chainfee.NewStaticEstimator(12500, 0),
2137-
GenSweepScript: func() ([]byte, error) { return nil, nil },
2138-
ContractBreaches: contractBreaches,
2139-
Signer: signer,
2140-
Notifier: notifier,
2141-
PublishTransaction: func(_ *wire.MsgTx, _ string) error { return nil },
2142-
Store: store,
2134+
CloseLink: func(_ *wire.OutPoint, _ ChannelCloseType) {},
2135+
DB: db.ChannelStateDB(),
2136+
Estimator: chainfee.NewStaticEstimator(12500, 0),
2137+
GenSweepScript: func() fn.Result[lnwallet.AddrWithKey] {
2138+
return fn.Ok(lnwallet.AddrWithKey{})
2139+
},
2140+
ContractBreaches: contractBreaches,
2141+
Signer: signer,
2142+
Notifier: notifier,
2143+
PublishTransaction: func(_ *wire.MsgTx, _ string) error {
2144+
return nil
2145+
},
2146+
Store: store,
21432147
})
21442148

21452149
if err := ba.Start(); err != nil {

server.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,16 +1172,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
11721172
CloseLink: closeLink,
11731173
DB: s.chanStateDB,
11741174
Estimator: s.cc.FeeEstimator,
1175-
GenSweepScript: func() ([]byte, error) {
1176-
addr, err := newSweepPkScriptGen(
1177-
cc.Wallet, netParams,
1178-
)().Unpack()
1179-
if err != nil {
1180-
return nil, err
1181-
}
1182-
1183-
return addr.DeliveryAddress, nil
1184-
},
1175+
GenSweepScript: newSweepPkScriptGen(
1176+
cc.Wallet, s.cfg.ActiveNetParams.Params,
1177+
),
11851178
Notifier: cc.ChainNotifier,
11861179
PublishTransaction: cc.Wallet.PublishTransaction,
11871180
ContractBreaches: contractBreaches,

0 commit comments

Comments
 (0)