lncli: update response handling for open/close channel
This commit updates the response handling of the steaming RPC’s to account for the fact that multiple messages from the server (state updates) can now be sent over the stream instead of a single final update. Currently, all updates other than the “final” update are ignored by the cli.
This commit is contained in:
parent
832fd248cd
commit
9eb2a4219f
@ -234,19 +234,22 @@ func openChannel(ctx *cli.Context) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
txid, err := wire.NewShaHash(resp.ChannelPoint.FundingTxid)
|
switch update := resp.Update.(type) {
|
||||||
|
case *lnrpc.OpenStatusUpdate_ChanOpen:
|
||||||
|
channelPoint := update.ChanOpen.ChannelPoint
|
||||||
|
txid, err := wire.NewShaHash(channelPoint.FundingTxid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
index := resp.ChannelPoint.OutputIndex
|
index := channelPoint.OutputIndex
|
||||||
printRespJson(struct {
|
printRespJson(struct {
|
||||||
ChannelPoint string `json:"channel_point"`
|
ChannelPoint string `json:"channel_point"`
|
||||||
}{
|
}{
|
||||||
ChannelPoint: fmt.Sprintf("%v:%v", txid, index),
|
ChannelPoint: fmt.Sprintf("%v:%v", txid, index),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -318,7 +321,22 @@ func closeChannel(ctx *cli.Context) error {
|
|||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
printRespJson(resp)
|
|
||||||
|
switch update := resp.Update.(type) {
|
||||||
|
case *lnrpc.CloseStatusUpdate_ChanClose:
|
||||||
|
closingHash := update.ChanClose.ClosingTxid
|
||||||
|
txid, err := wire.NewShaHash(closingHash)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
printRespJson(struct {
|
||||||
|
ClosingTXID string `json:"closing_txid"`
|
||||||
|
}{
|
||||||
|
ClosingTXID: txid.String(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user