@@ -99,7 +99,6 @@ const (
9999 // you and limitless channel size (apart from 21 million cap).
100100 MaxBtcFundingAmountWumbo = btcutil .Amount (1000000000 )
101101
102- // TODO(roasbeef): tune.
103102 msgBufferSize = 50
104103
105104 // MaxWaitNumBlocksFundingConf is the maximum number of blocks to wait
@@ -1256,8 +1255,8 @@ func (f *Manager) stateStep(channel *channeldb.OpenChannel,
12561255
12571256// advancePendingChannelState waits for a pending channel's funding tx to
12581257// confirm, and marks it open in the database when that happens.
1259- func (f * Manager ) advancePendingChannelState (
1260- channel * channeldb. OpenChannel , pendingChanID PendingChanID ) error {
1258+ func (f * Manager ) advancePendingChannelState (channel * channeldb. OpenChannel ,
1259+ pendingChanID PendingChanID ) error {
12611260
12621261 if channel .IsZeroConf () {
12631262 // Persist the alias to the alias database.
@@ -2244,10 +2243,27 @@ func (f *Manager) waitForPsbt(intent *chanfunding.PsbtIntent,
22442243 return
22452244 }
22462245
2246+ // At this point, we'll see if there's an AuxFundingDesc we
2247+ // need to deliver so the funding process can continue
2248+ // properly.
2249+ chanState := resCtx .reservation .ChanState ()
2250+ localKeys , remoteKeys := resCtx .reservation .CommitmentKeyRings ()
2251+ auxFundingDesc , err := descFromPendingChanID (
2252+ f .cfg .AuxFundingController , cid .tempChanID , chanState ,
2253+ * localKeys , * remoteKeys , true ,
2254+ )
2255+ if err != nil {
2256+ failFlow ("error continuing PSBT flow" , err )
2257+ return
2258+ }
2259+
22472260 // A non-nil error means we can continue the funding flow.
22482261 // Notify the wallet so it can prepare everything we need to
22492262 // continue.
2250- err = resCtx .reservation .ProcessPsbt ()
2263+ //
2264+ // We'll also pass along the aux funding controller as well,
2265+ // which may be used to help process the finalized PSBT.
2266+ err = resCtx .reservation .ProcessPsbt (auxFundingDesc )
22512267 if err != nil {
22522268 failFlow ("error continuing PSBT flow" , err )
22532269 return
@@ -2373,7 +2389,6 @@ func (f *Manager) fundeeProcessFundingCreated(peer lnpeer.Peer,
23732389 // final funding transaction, as well as a signature for our version of
23742390 // the commitment transaction. So at this point, we can validate the
23752391 // initiator's commitment transaction, then send our own if it's valid.
2376- // TODO(roasbeef): make case (p vs P) consistent throughout
23772392 fundingOut := msg .FundingPoint
23782393 log .Infof ("completing pending_id(%x) with ChannelPoint(%v)" ,
23792394 pendingChanID [:], fundingOut )
@@ -2405,16 +2420,33 @@ func (f *Manager) fundeeProcessFundingCreated(peer lnpeer.Peer,
24052420 }
24062421 }
24072422
2423+ // At this point, we'll see if there's an AuxFundingDesc we need to
2424+ // deliver so the funding process can continue properly.
2425+ chanState := resCtx .reservation .ChanState ()
2426+ localKeys , remoteKeys := resCtx .reservation .CommitmentKeyRings ()
2427+ auxFundingDesc , err := descFromPendingChanID (
2428+ f .cfg .AuxFundingController , cid .tempChanID , chanState ,
2429+ * localKeys , * remoteKeys , true ,
2430+ )
2431+ if err != nil {
2432+ log .Errorf ("error continuing PSBT flow: %v" , err )
2433+ f .failFundingFlow (peer , cid , err )
2434+ return
2435+ }
2436+
24082437 // With all the necessary data available, attempt to advance the
24092438 // funding workflow to the next stage. If this succeeds then the
24102439 // funding transaction will broadcast after our next message.
24112440 // CompleteReservationSingle will also mark the channel as 'IsPending'
24122441 // in the database.
2442+ //
2443+ // We'll also directly pass in the AuxFundiner controller as well,
2444+ // which may be used by the reservation system to finalize funding our
2445+ // side.
24132446 completeChan , err := resCtx .reservation .CompleteReservationSingle (
2414- & fundingOut , commitSig ,
2447+ & fundingOut , commitSig , auxFundingDesc ,
24152448 )
24162449 if err != nil {
2417- // TODO(roasbeef): better error logging: peerID, channelID, etc.
24182450 log .Errorf ("unable to complete single reservation: %v" , err )
24192451 f .failFundingFlow (peer , cid , err )
24202452 return
@@ -2725,9 +2757,6 @@ func (f *Manager) funderProcessFundingSigned(peer lnpeer.Peer,
27252757
27262758 // Send an update to the upstream client that the negotiation process
27272759 // is over.
2728- //
2729- // TODO(roasbeef): add abstraction over updates to accommodate
2730- // long-polling, or SSE, etc.
27312760 upd := & lnrpc.OpenStatusUpdate {
27322761 Update : & lnrpc.OpenStatusUpdate_ChanPending {
27332762 ChanPending : & lnrpc.PendingUpdate {
@@ -3634,7 +3663,7 @@ func (f *Manager) annAfterSixConfs(completeChan *channeldb.OpenChannel,
36343663// a zero-conf channel. This will wait for the real confirmation, add the
36353664// confirmed SCID to the router graph, and then announce after six confs.
36363665func (f * Manager ) waitForZeroConfChannel (c * channeldb.OpenChannel ,
3637- pendingID PendingChanID ) error {
3666+ _ PendingChanID ) error {
36383667
36393668 // First we'll check whether the channel is confirmed on-chain. If it
36403669 // is already confirmed, the chainntnfs subsystem will return with the
@@ -4432,7 +4461,6 @@ func (f *Manager) announceChannel(localIDKey, remoteIDKey *btcec.PublicKey,
44324461
44334462// InitFundingWorkflow sends a message to the funding manager instructing it
44344463// to initiate a single funder workflow with the source peer.
4435- // TODO(roasbeef): re-visit blocking nature..
44364464func (f * Manager ) InitFundingWorkflow (msg * InitFundingMsg ) {
44374465 f .fundingRequests <- msg
44384466}
0 commit comments