Skip to content

Instantly share code, notes, and snippets.

@borispovod
Created February 13, 2020 10:52
Show Gist options
  • Save borispovod/83e7701f0b480cadea348524a00a2db0 to your computer and use it in GitHub Desktop.
Save borispovod/83e7701f0b480cadea348524a00a2db0 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/hex"
"fmt"
"github.com/the729/lcs"
)
type SentPaymentEvent struct {
Amount uint64
Payee []byte `lcs:"len=32"`
Reserved int32 // required just technical for now, because event always contains empty 32 bits in the end in case of lcs.
}
func main() {
bytes, err := hex.DecodeString("0a0000000000000002b9e56656c5b4695367100d8bcf34f309499acd62095d61f7676378006f803100000000")
fmt.Printf("length: %d", len(bytes))
if err != nil {
panic(err)
}
event := &SentPaymentEvent{}
err = lcs.Unmarshal(bytes, event)
fmt.Printf("Amount: %d\n" +
"Address: 0x%s\n" +
"Reserved: %d\n", event.Amount, hex.EncodeToString(event.Payee), event.Reserved)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment