receipt.go
TEXT FILE1.0 KB · Public source code for developers, search crawlers and AI agents
1package stage2
2
3import (
4 "encoding/json"
5 "errors"
6 "fmt"
7)
8
9type SendResponse struct {
10 OK bool `json:"ok"`
11 ReplySource string `json:"reply_source"`
12 Result struct {
13 OK bool `json:"ok"`
14 Result struct {
15 Requested int64 `json:"requested_sat"`
16 Recipient int64 `json:"recipient_sat"`
17 Change int64 `json:"change_sat"`
18 TXID string `json:"txid"`
19 Net string `json:"net"`
20 } `json:"result"`
21 } `json:"result"`
22}
23
24func ParseSend(data []byte) (SendResponse, error) {
25 var r SendResponse
26 if err := json.Unmarshal(data, &r); err != nil {
27 return r, err
28 }
29 if !r.OK || !r.Result.OK || r.Result.Result.TXID == "" {
30 return r, errors.New("missing accepted send result")
31 }
32 return r, nil
33}
34func Receipt(r SendResponse) string {
35 v := r.Result.Result
36 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)
37}Read-only source · Select a line number to link directly · Raw download above
