Merge pull request #7728 from shaurya947/memo-pending-channels

lnrpc+itest: return channel Memo for Pending channels
This commit is contained in:
Oliver Gugger 2023-06-16 18:34:30 +02:00 committed by GitHub
commit 02c1261a3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1813 additions and 1773 deletions

View file

@ -459,6 +459,7 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
const (
firstChanSize = 1_000_000
anchorFeeBuffer = 500_000
testMemo = "bob is a good peer"
)
ht.FundCoins(firstChanSize+anchorFeeBuffer, alice)
@ -466,7 +467,8 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
// fully.
aliceChanPoint1 := ht.OpenChannel(
alice, bob, lntest.OpenChannelParams{
Amt: firstChanSize,
Amt: firstChanSize,
Memo: testMemo,
},
)
@ -509,6 +511,12 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
// PendingChannels RPC under the waiting close section.
waitingClose := ht.AssertChannelWaitingClose(alice, aliceChanPoint1)
// Verify that the channel Memo is returned even for channels that are
// waiting close (close TX broadcasted but not confirmed)
pendingChannelsResp := alice.RPC.PendingChannels()
require.Equal(ht, testMemo,
pendingChannelsResp.WaitingCloseChannels[0].Channel.Memo)
// At this point, the channel is waiting close, and we have both the
// commitment transaction and anchor sweep in the mempool.
const expectedTxns = 2
@ -531,6 +539,12 @@ func testAnchorThirdPartySpend(ht *lntest.HarnessTest) {
// on the number of anchor channels.
ht.AssertChannelPendingForceClose(alice, aliceChanPoint1)
// Verify that the channel Memo is returned even for channels that are
// pending force close (close TX confirmed but sweep hasn't happened)
pendingChannelsResp = alice.RPC.PendingChannels()
require.Equal(ht, testMemo,
pendingChannelsResp.PendingForceClosingChannels[0].Channel.Memo)
// With the anchor output located, and the main commitment mined we'll
// instruct the wallet to send all coins in the wallet to a new address
// (to the miner), including unconfirmed change.

File diff suppressed because it is too large Load diff

View file

@ -2556,6 +2556,13 @@ message PendingChannelsResponse {
// Whether this channel is advertised to the network or not.
bool private = 12;
/*
An optional note-to-self to go along with the channel containing some
useful information. This is only ever stored locally and in no way
impacts the channel's operation.
*/
string memo = 13;
}
message PendingOpenChannel {

View file

@ -3028,6 +3028,10 @@
"private": {
"type": "boolean",
"description": "Whether this channel is advertised to the network or not."
},
"memo": {
"type": "string",
"description": "An optional note-to-self to go along with the channel containing some\nuseful information. This is only ever stored locally and in no way\nimpacts the channel's operation."
}
}
},

View file

@ -3424,6 +3424,7 @@ func (r *rpcServer) fetchPendingOpenChannels() (pendingOpenChannels, error) {
Initiator: rpcInitiator(pendingChan.IsInitiator),
CommitmentType: rpcCommitmentType(pendingChan.ChanType),
Private: isPrivate(pendingChan),
Memo: string(pendingChan.Memo),
},
CommitWeight: commitWeight,
CommitFee: int64(localCommitment.CommitFee),
@ -3513,6 +3514,7 @@ func (r *rpcServer) fetchPendingForceCloseChannels() (pendingForceClose,
)
channel.Private = isPrivate(historical)
channel.Memo = string(historical.Memo)
// If the error is non-nil, and not due to older versions of lnd
// not persisting historical channels, return it.
@ -3715,6 +3717,7 @@ func (r *rpcServer) fetchWaitingCloseChannels() (waitingCloseChannels,
NumForwardingPackages: int64(len(fwdPkgs)),
ChanStatusFlags: waitingClose.ChanStatus().String(),
Private: isPrivate(waitingClose),
Memo: string(waitingClose.Memo),
}
waitingCloseResp := &lnrpc.PendingChannelsResponse_WaitingCloseChannel{