1 Star 0 Fork 0

cevin/btcd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.go 1.38 KB
一键复制 编辑 原始数据 按行查看 历史
cevin 提交于 2024-01-19 15:00 . fix: CVE-2023-48795 CVE-2023-44487
package main
import (
"btc/web"
"flag"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"runtime"
)
var (
version = "main"
gitCommitHash = ""
)
func main() {
var addr string
flag.StringVar(&addr, "addr", "localhost:8000", "")
flag.Parse()
app := echo.New()
app.Use(middleware.Recover())
app.Use(middleware.CORS())
app.Use(middleware.RequestID())
app.Use(middleware.Logger())
app.HideBanner = true
app.RouteNotFound("/*", web.DefaultNotFound)
// info
app.Any("/", func(c echo.Context) error {
return c.JSON(200, struct {
Code int `json:"code"`
Version string `json:"version"`
GoVersion string `json:"go-version"`
GitHash string `json:"git-commit-hash"`
}{
Code: 200,
Version: version,
GoVersion: runtime.Version(),
GitHash: gitCommitHash,
})
})
// addresses
app.Match([]string{"GET", "POST"}, "/address/new", web.NewAddress)
app.Match([]string{"GET", "POST"}, "/address/parse", web.ParseAddress)
app.Match([]string{"GET", "POST"}, "/address/new-multi-sig", web.NewMultiSigAddress)
// transactions
app.Match([]string{"GET", "POST"}, "/transaction/decode", web.DecodeTransaction)
app.POST("/transaction/create", web.CreateRawTransaction)
app.POST("/transaction/sign", web.SignTransaction)
app.POST("/transaction/create-and-sign", web.CreateAndSignTransaction)
app.Logger.Fatal(app.Start(addr))
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/cevinc/btcd.git
git@gitee.com:cevinc/btcd.git
cevinc
btcd
btcd
main

搜索帮助