rpc+lnwallet: implement new FundingStateStep RPC method
In this commit, we implement the currently defined transition methods for the new `FundingStateStep` method. At this point, we're now able to serve the "responder" of the externally initiated channel funding flow by being able to register and cancel a funding flow according to its expected pending channel ID.
This commit is contained in:
3 files changed
+95
-11
No files matched your search
+23
-1
@@ -450,8 +450,30 @@ func (l *LightningWallet) RegisterFundingIntent(expectedID [32]byte,
|
||||
shimIntent chanfunding.Intent) error {
|
||||
|
||||
l.intentMtx.Lock()
|
||||
defer l.intentMtx.Unlock()
|
||||
|
||||
if _, ok := l.fundingIntents[expectedID]; ok {
|
||||
return fmt.Errorf("pendingChanID(%x) already has intent "+
|
||||
"registered", expectedID[:])
|
||||
}
|
||||
|
||||
l.fundingIntents[expectedID] = shimIntent
|
||||
l.intentMtx.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// CancelFundingIntent allows a caller to cancel a previously registered
|
||||
// funding intent. If no intent was found, then an error will be returned.
|
||||
func (l *LightningWallet) CancelFundingIntent(pid [32]byte) error {
|
||||
l.intentMtx.Lock()
|
||||
defer l.intentMtx.Unlock()
|
||||
|
||||
if _, ok := l.fundingIntents[pid]; !ok {
|
||||
return fmt.Errorf("no funding intent found for "+
|
||||
"pendingChannelID(%x)", pid[:])
|
||||
}
|
||||
|
||||
delete(l.fundingIntents, pid)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user