mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-09 23:12:46 +02:00
multi: Use user provided close address for cooperative closes
This commit is adapted from @Bluetegu's original pull request #1462. This commit reads an optional address to pay funds out to from a user iniitiated close channel address. If the channel already has a shutdown script set, the request will fail if an address is provided. Otherwise, the cooperative close will pay out to the address provided.
This commit is contained in:
22
rpcserver.go
22
rpcserver.go
@@ -1881,8 +1881,28 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
// cooperative channel closure. So we'll forward the request to
|
||||
// the htlc switch which will handle the negotiation and
|
||||
// broadcast details.
|
||||
|
||||
var deliveryScript lnwire.DeliveryAddress
|
||||
|
||||
// If a delivery address to close out to was specified, decode it.
|
||||
if len(in.DeliveryAddress) > 0 {
|
||||
// Decode the address provided.
|
||||
addr, err := btcutil.DecodeAddress(
|
||||
in.DeliveryAddress, activeNetParams.Params,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid delivery address: %v", err)
|
||||
}
|
||||
|
||||
// Create a script to pay out to the address provided.
|
||||
deliveryScript, err = txscript.PayToAddrScript(addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
updateChan, errChan = r.server.htlcSwitch.CloseLink(
|
||||
chanPoint, htlcswitch.CloseRegular, feeRate,
|
||||
chanPoint, htlcswitch.CloseRegular, feeRate, deliveryScript,
|
||||
)
|
||||
}
|
||||
out:
|
||||
|
Reference in New Issue
Block a user