Created
February 13, 2020 10:52
-
-
Save borispovod/83e7701f0b480cadea348524a00a2db0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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