peer+contractcourt: delegate watching for co-op closes to the chainWatcher
In this commit, we modify the interaction between the chanCloser sub-system and the chain notifier all together. This fixes a series of bugs as before this commit, we wouldn’t be able to detect if the remote party actually broadcasted *any* of the transactions that we signed off upon. This would be rejected to the user by having a “zombie” channel close that would never actually be resolved. Rather than the chanCloser watching for on-chain closes, we’ll now open up a co-op close context to the chainWatcher (via a layer of indirection via the ChainArbitrator), and report to it all possible closes that we’ve signed. The chainWatcher will then be able to launch a goroutine to properly update the database state once any of the possible closure transactions confirms.
This commit is contained in:
5 files changed
+201
-32
No files matched your search
+8
-8
@@ -88,7 +88,7 @@ func TestPeerChannelClosureAcceptFeeResponder(t *testing.T) {
|
||||
// We accept the fee, and send a ClosingSigned with the same fee back,
|
||||
// so she knows we agreed.
|
||||
peerFee := responderClosingSigned.FeeSatoshis
|
||||
initiatorSig, err := initiatorChan.CreateCloseProposal(
|
||||
initiatorSig, _, _, err := initiatorChan.CreateCloseProposal(
|
||||
peerFee, dummyDeliveryScript, respDeliveryScript,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -178,7 +178,7 @@ func TestPeerChannelClosureAcceptFeeInitiator(t *testing.T) {
|
||||
t.Fatalf("unable to query fee estimator: %v", err)
|
||||
}
|
||||
fee := btcutil.Amount(responderChan.CalcFee(uint64(feeRate * 1000)))
|
||||
closeSig, err := responderChan.CreateCloseProposal(fee,
|
||||
closeSig, _, _, err := responderChan.CreateCloseProposal(fee,
|
||||
dummyDeliveryScript, initiatorDeliveryScript)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create close proposal: %v", err)
|
||||
@@ -287,7 +287,7 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
||||
// We don't agree with the fee, and will send back one that's 2.5x.
|
||||
preferredRespFee := responderClosingSigned.FeeSatoshis
|
||||
increasedFee := btcutil.Amount(float64(preferredRespFee) * 2.5)
|
||||
initiatorSig, err := initiatorChan.CreateCloseProposal(
|
||||
initiatorSig, _, _, err := initiatorChan.CreateCloseProposal(
|
||||
increasedFee, dummyDeliveryScript, respDeliveryScript,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -331,7 +331,7 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
||||
|
||||
// We try negotiating a 2.1x fee, which should also be rejected.
|
||||
increasedFee = btcutil.Amount(float64(preferredRespFee) * 2.1)
|
||||
initiatorSig, err = initiatorChan.CreateCloseProposal(
|
||||
initiatorSig, _, _, err = initiatorChan.CreateCloseProposal(
|
||||
increasedFee, dummyDeliveryScript, respDeliveryScript,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -376,7 +376,7 @@ func TestPeerChannelClosureFeeNegotiationsResponder(t *testing.T) {
|
||||
|
||||
// Finally, we'll accept the fee by echoing back the same fee that they
|
||||
// sent to us.
|
||||
initiatorSig, err = initiatorChan.CreateCloseProposal(
|
||||
initiatorSig, _, _, err = initiatorChan.CreateCloseProposal(
|
||||
peerFee, dummyDeliveryScript, respDeliveryScript,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -471,7 +471,7 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
|
||||
uint64(initiatorIdealFeeRate * 1000),
|
||||
)
|
||||
increasedFee := btcutil.Amount(float64(initiatorIdealFee) * 2.5)
|
||||
closeSig, err := responderChan.CreateCloseProposal(
|
||||
closeSig, _, _, err := responderChan.CreateCloseProposal(
|
||||
increasedFee, dummyDeliveryScript, initiatorDeliveryScript,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -536,7 +536,7 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
|
||||
|
||||
// We try negotiating a 2.1x fee, which should also be rejected.
|
||||
increasedFee = btcutil.Amount(float64(initiatorIdealFee) * 2.1)
|
||||
responderSig, err := responderChan.CreateCloseProposal(
|
||||
responderSig, _, _, err := responderChan.CreateCloseProposal(
|
||||
increasedFee, dummyDeliveryScript, initiatorDeliveryScript,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -582,7 +582,7 @@ func TestPeerChannelClosureFeeNegotiationsInitiator(t *testing.T) {
|
||||
|
||||
// At this point, we'll accept their fee by sending back a CloseSigned
|
||||
// message with an identical fee.
|
||||
responderSig, err = responderChan.CreateCloseProposal(
|
||||
responderSig, _, _, err = responderChan.CreateCloseProposal(
|
||||
peerFee, dummyDeliveryScript, initiatorDeliveryScript,
|
||||
)
|
||||
if err != nil {
|
||||
|
||||
Reference in new issue
Block a user