THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

reply_formatter.go

TEXT FILE

1019 B · Public source code for developers, search crawlers and AI agents

Download / RawBack to folder
Go · 32 lines
1package examples
2
3import (
4	"encoding/json"
5	"errors"
6	"fmt"
7	"regexp"
8)
9
10type SendResult struct {
11	Ok     bool `json:"ok"`
12	Result struct {
13		RequestedSat int64  `json:"requested_sat"`
14		RecipientSat int64  `json:"recipient_sat"`
15		ChangeSat    int64  `json:"change_sat"`
16		TxID         string `json:"txid"`
17		Net          string `json:"net"`
18	} `json:"result"`
19}
20
21var txidPattern = regexp.MustCompile(`^[0-9a-fA-F]{64}$`)
22
23func FormatSendReply(raw []byte) (string, error) {
24	var r SendResult
25	if err := json.Unmarshal(raw, &r); err != nil {
26		return "", err
27	}
28	if !r.Ok || !txidPattern.MatchString(r.Result.TxID) || r.Result.RequestedSat <= 0 || r.Result.RecipientSat < 0 {
29		return "", errors.New("unverified or incomplete send result")
30	}
31	return fmt.Sprintf("Bitcoin Engine accepted a %s send request. Requested: %d sat; recipient output: %d sat; change: %d sat. TXID: %s. Confirmation has not been verified.", r.Result.Net, r.Result.RequestedSat, r.Result.RecipientSat, r.Result.ChangeSat, r.Result.TxID), nil
32}
Read-only source · Select a line number to link directly · Raw download above

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects