Merge pull request #3722 from Roasbeef/external-funding-rpc
lnrpc+lnwallet+funding: implement new RPCs to enable external channel funding
This commit is contained in:
10 files changed
+1839
-711
No files matched your search
@@ -154,15 +154,9 @@ func NewCannedAssembler(chanPoint wire.OutPoint, fundingAmt btcutil.Amount,
|
||||
//
|
||||
// NOTE: This method satisfies the chanfunding.Assembler interface.
|
||||
func (c *CannedAssembler) ProvisionChannel(req *Request) (Intent, error) {
|
||||
switch {
|
||||
// A simple sanity check to ensure the provision request matches the
|
||||
// re-made shim intent.
|
||||
case req.LocalAmt != c.fundingAmt:
|
||||
return nil, fmt.Errorf("intent doesn't match canned assembler")
|
||||
|
||||
// We'll exit out if this field is set as the funding transaction has
|
||||
// already been assembled, so we don't influence coin selection..
|
||||
case req.SubtractFees:
|
||||
if req.SubtractFees {
|
||||
return nil, fmt.Errorf("SubtractFees ignored, funding " +
|
||||
"transaction is frozen")
|
||||
}
|
||||
@@ -179,6 +173,14 @@ func (c *CannedAssembler) ProvisionChannel(req *Request) (Intent, error) {
|
||||
intent.remoteFundingAmt = c.fundingAmt
|
||||
}
|
||||
|
||||
// A simple sanity check to ensure the provisioned request matches the
|
||||
// re-made shim intent.
|
||||
if req.LocalAmt+req.RemoteAmt != c.fundingAmt {
|
||||
return nil, fmt.Errorf("intent doesn't match canned "+
|
||||
"assembler: local_amt=%v, remote_amt=%v, funding_amt=%v",
|
||||
req.LocalAmt, req.RemoteAmt, c.fundingAmt)
|
||||
}
|
||||
|
||||
return intent, nil
|
||||
}
|
||||
|
||||
|
||||
+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