package stage2 import ( "encoding/json" "errors" "fmt" ) type SendResponse struct { OK bool `json:"ok"` ReplySource string `json:"reply_source"` Result struct { OK bool `json:"ok"` Result struct { Requested int64 `json:"requested_sat"` Recipient int64 `json:"recipient_sat"` Change int64 `json:"change_sat"` TXID string `json:"txid"` Net string `json:"net"` } `json:"result"` } `json:"result"` } func ParseSend(data []byte) (SendResponse, error) { var r SendResponse if err := json.Unmarshal(data, &r); err != nil { return r, err } if !r.OK || !r.Result.OK || r.Result.Result.TXID == "" { return r, errors.New("missing accepted send result") } return r, nil } func Receipt(r SendResponse) string { v := r.Result.Result return fmt.Sprintf("Bitcoin Engine accepted a %s send request for %d sats. Recipient output: %d sats. Change output: %d sats. TXID: %s. Confirmation has not been verified.", v.Net, v.Requested, v.Recipient, v.Change, v.TXID) }