Skip to content

Commit

Permalink
cln: Add serialization of the getswap command return
Browse files Browse the repository at this point in the history
The enums role and type have been returned as int values. For
a better human readability we now return them as string
  • Loading branch information
nepet committed Sep 29, 2022
1 parent e9dc2b4 commit 90362f0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clightning/clightning_commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ func (g *GetSwap) Call() (jrpc2.Result, error) {
if err != nil {
return nil, err
}
return swap, nil
return MSerializedSwapStateMachine(swap), nil
}

func (g *GetSwap) Get(client *ClightningClient) jrpc2.ServerMethod {
Expand Down
19 changes: 19 additions & 0 deletions clightning/serializing.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package clightning

import "github.com/elementsproject/peerswap/swap"

// SerializedSwapStateMachine is the serialized representation of the internal
// state machine with all these massive (and unnecessary) amounts of data.
type SerializedSwapStateMachine struct {
*swap.SwapStateMachine
Type string `json:"type"`
Role string `json:"role"`
}

func MSerializedSwapStateMachine(swapStateMachine *swap.SwapStateMachine) *SerializedSwapStateMachine {
return &SerializedSwapStateMachine{
SwapStateMachine: swapStateMachine,
Type: swapStateMachine.Type.String(),
Role: swapStateMachine.Role.String(),
}
}

0 comments on commit 90362f0

Please sign in to comment.