// Command nostrino-profile prints a chain profile as the JSON file a client, a bridge or a // browser wallet loads. // // It exists because a forked chain's profile is data, not a name: the fork height, its target // shift and the checkpoint below it have no built-in spelling, so the operator needs one file to // hand around. package main import ( "flag" "fmt" "os" "git.smesh.lol/nostrino/pkg/chain" ) func main() { chainName := flag.String("chain", "xbt", "profile name: btc, xbt, regtest, signet or testnet3") cpHeight := flag.Uint("checkpoint-height", 0, "checkpoint height to add (0 = none)") cpHash := flag.String("checkpoint-hash", "", "checkpoint block hash (display order)") cpFilter := flag.String("checkpoint-filter-header", "", "checkpoint filter header (display order)") out := flag.String("out", "", "write here (default standard output)") flag.Parse() profile, err := chain.ByName(*chainName) if err != nil { fail(err) } if *cpHeight != 0 || *cpHash != "" || *cpFilter != "" { cp, err := chain.ParseCheckpoint(uint32(*cpHeight), *cpHash, *cpFilter) if err != nil { fail(err) } profile.Checkpoint = cp } if err := profile.Validate(); err != nil { fail(err) } body, err := chain.MarshalProfile(profile) if err != nil { fail(err) } if *out == "" { fmt.Println(string(body)) return } if err := os.WriteFile(*out, append(body, '\n'), 0o644); err != nil { fail(err) } } func fail(err error) { fmt.Fprintln(os.Stderr, "nostrino-profile:", err) os.Exit(1) }