Commit 5489c408 authored by szh's avatar szh

add uuid

parent 62e87db6
...@@ -10,6 +10,7 @@ import ( ...@@ -10,6 +10,7 @@ import (
"ffie-admin/server/service" "ffie-admin/server/service"
"ffie-admin/server/utils" "ffie-admin/server/utils"
"fmt" "fmt"
"time"
"github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt" "github.com/btcsuite/btcd/btcutil/psbt"
...@@ -144,7 +145,7 @@ func (brcLockApi *BrcLockApi) UpdateBrcLock(c *gin.Context) { ...@@ -144,7 +145,7 @@ func (brcLockApi *BrcLockApi) UpdateBrcLock(c *gin.Context) {
} }
} }
// UpdateLock 更新BrcLock // UpdateLock 更新BrcLock Hash
// @Tags BrcLock // @Tags BrcLock
// @Summary 更新BrcLock // @Summary 更新BrcLock
// @accept application/json // @accept application/json
...@@ -162,11 +163,15 @@ func (brcLockApi *BrcLockApi) UpdateLock(c *gin.Context) { ...@@ -162,11 +163,15 @@ func (brcLockApi *BrcLockApi) UpdateLock(c *gin.Context) {
verify := utils.Rules{ verify := utils.Rules{
"Status": {utils.NotEmpty()}, "Status": {utils.NotEmpty()},
} }
if brcLock.ID == 0 && brcLock.Uuid == "" {
response.FailWithMessage("参数错误", c)
return
}
if err := utils.Verify(brcLock, verify); err != nil { if err := utils.Verify(brcLock, verify); err != nil {
response.FailWithMessage(err.Error(), c) response.FailWithMessage(err.Error(), c)
return return
} }
if err := brcLockService.UpdateBrcLock(brcLock); err != nil { if err := brcLockService.UpdateLockHashByUuid(brcLock.Uuid, brcLock.Hash); err != nil {
global.GVA_LOG.Error("更新失败!", zap.Error(err)) global.GVA_LOG.Error("更新失败!", zap.Error(err))
response.FailWithMessage("更新失败", c) response.FailWithMessage("更新失败", c)
} else { } else {
...@@ -394,6 +399,9 @@ func (brcLockApi *BrcLockApi) BuildBrc20Tx(c *gin.Context) { ...@@ -394,6 +399,9 @@ func (brcLockApi *BrcLockApi) BuildBrc20Tx(c *gin.Context) {
"Ticker": {utils.NotEmpty()}, "Ticker": {utils.NotEmpty()},
"Amount": {utils.NotEmpty()}, "Amount": {utils.NotEmpty()},
"UTXOs": {utils.NotEmpty()}, "UTXOs": {utils.NotEmpty()},
"Period": {utils.NotEmpty()},
"StartTime": {utils.NotEmpty()},
"Uuid": {utils.NotEmpty()},
} }
if err := utils.Verify(req, verify); err != nil { if err := utils.Verify(req, verify); err != nil {
response.FailWithMessage(err.Error(), c) response.FailWithMessage(err.Error(), c)
...@@ -405,6 +413,19 @@ func (brcLockApi *BrcLockApi) BuildBrc20Tx(c *gin.Context) { ...@@ -405,6 +413,19 @@ func (brcLockApi *BrcLockApi) BuildBrc20Tx(c *gin.Context) {
response.FailWithMessage(err.Error(), c) response.FailWithMessage(err.Error(), c)
return return
} }
psbtStr.Uuid = req.Uuid
period := int(req.Period)
startTime := time.Unix(int64(req.StartTime), 0)
if err := brcLockService.CreateBrcLock(brc.BrcLock{
Period: &period,
LockAddr: req.ToAddress,
Addr: req.FromAddress,
StartTime: &startTime,
Uuid: req.Uuid,
}); err != nil {
response.FailWithMessage(err.Error(), c)
return
}
response.OkWithData(psbtStr, c) response.OkWithData(psbtStr, c)
} }
......
...@@ -2194,6 +2194,11 @@ var doc = `{ ...@@ -2194,6 +2194,11 @@ var doc = `{
"description": "更新时间", "description": "更新时间",
"name": "updatedAt", "name": "updatedAt",
"in": "query" "in": "query"
},
{
"type": "string",
"name": "uuid",
"in": "query"
} }
], ],
"responses": { "responses": {
...@@ -2309,6 +2314,11 @@ var doc = `{ ...@@ -2309,6 +2314,11 @@ var doc = `{
"description": "更新时间", "description": "更新时间",
"name": "updatedAt", "name": "updatedAt",
"in": "query" "in": "query"
},
{
"type": "string",
"name": "uuid",
"in": "query"
} }
], ],
"responses": { "responses": {
...@@ -2419,6 +2429,11 @@ var doc = `{ ...@@ -2419,6 +2429,11 @@ var doc = `{
"description": "更新时间", "description": "更新时间",
"name": "updatedAt", "name": "updatedAt",
"in": "query" "in": "query"
},
{
"type": "string",
"name": "uuid",
"in": "query"
} }
], ],
"responses": { "responses": {
...@@ -5756,6 +5771,9 @@ var doc = `{ ...@@ -5756,6 +5771,9 @@ var doc = `{
"updatedAt": { "updatedAt": {
"description": "更新时间", "description": "更新时间",
"type": "string" "type": "string"
},
"uuid": {
"type": "string"
} }
} }
}, },
...@@ -7008,6 +7026,14 @@ var doc = `{ ...@@ -7008,6 +7026,14 @@ var doc = `{
"fromAddress": { "fromAddress": {
"type": "string" "type": "string"
}, },
"period": {
"description": "锁定周期",
"type": "integer"
},
"startTime": {
"description": "锁定时间",
"type": "integer"
},
"ticker": { "ticker": {
"description": "代币符号FFFF", "description": "代币符号FFFF",
"type": "string" "type": "string"
...@@ -7021,6 +7047,9 @@ var doc = `{ ...@@ -7021,6 +7047,9 @@ var doc = `{
"items": { "items": {
"type": "string" "type": "string"
} }
},
"uuid": {
"type": "string"
} }
} }
}, },
......
...@@ -2178,6 +2178,11 @@ ...@@ -2178,6 +2178,11 @@
"description": "更新时间", "description": "更新时间",
"name": "updatedAt", "name": "updatedAt",
"in": "query" "in": "query"
},
{
"type": "string",
"name": "uuid",
"in": "query"
} }
], ],
"responses": { "responses": {
...@@ -2293,6 +2298,11 @@ ...@@ -2293,6 +2298,11 @@
"description": "更新时间", "description": "更新时间",
"name": "updatedAt", "name": "updatedAt",
"in": "query" "in": "query"
},
{
"type": "string",
"name": "uuid",
"in": "query"
} }
], ],
"responses": { "responses": {
...@@ -2403,6 +2413,11 @@ ...@@ -2403,6 +2413,11 @@
"description": "更新时间", "description": "更新时间",
"name": "updatedAt", "name": "updatedAt",
"in": "query" "in": "query"
},
{
"type": "string",
"name": "uuid",
"in": "query"
} }
], ],
"responses": { "responses": {
...@@ -5740,6 +5755,9 @@ ...@@ -5740,6 +5755,9 @@
"updatedAt": { "updatedAt": {
"description": "更新时间", "description": "更新时间",
"type": "string" "type": "string"
},
"uuid": {
"type": "string"
} }
} }
}, },
...@@ -6992,6 +7010,14 @@ ...@@ -6992,6 +7010,14 @@
"fromAddress": { "fromAddress": {
"type": "string" "type": "string"
}, },
"period": {
"description": "锁定周期",
"type": "integer"
},
"startTime": {
"description": "锁定时间",
"type": "integer"
},
"ticker": { "ticker": {
"description": "代币符号FFFF", "description": "代币符号FFFF",
"type": "string" "type": "string"
...@@ -7005,6 +7031,9 @@ ...@@ -7005,6 +7031,9 @@
"items": { "items": {
"type": "string" "type": "string"
} }
},
"uuid": {
"type": "string"
} }
} }
}, },
......
...@@ -49,6 +49,8 @@ definitions: ...@@ -49,6 +49,8 @@ definitions:
updatedAt: updatedAt:
description: 更新时间 description: 更新时间
type: string type: string
uuid:
type: string
type: object type: object
config.AliyunOSS: config.AliyunOSS:
properties: properties:
...@@ -924,6 +926,12 @@ definitions: ...@@ -924,6 +926,12 @@ definitions:
type: integer type: integer
fromAddress: fromAddress:
type: string type: string
period:
description: 锁定周期
type: integer
startTime:
description: 锁定时间
type: integer
ticker: ticker:
description: 代币符号FFFF description: 代币符号FFFF
type: string type: string
...@@ -934,6 +942,8 @@ definitions: ...@@ -934,6 +942,8 @@ definitions:
items: items:
type: string type: string
type: array type: array
uuid:
type: string
type: object type: object
request.Login: request.Login:
properties: properties:
...@@ -2964,6 +2974,9 @@ paths: ...@@ -2964,6 +2974,9 @@ paths:
in: query in: query
name: updatedAt name: updatedAt
type: string type: string
- in: query
name: uuid
type: string
produces: produces:
- application/json - application/json
responses: responses:
...@@ -3035,6 +3048,9 @@ paths: ...@@ -3035,6 +3048,9 @@ paths:
in: query in: query
name: updatedAt name: updatedAt
type: string type: string
- in: query
name: uuid
type: string
produces: produces:
- application/json - application/json
responses: responses:
...@@ -3106,6 +3122,9 @@ paths: ...@@ -3106,6 +3122,9 @@ paths:
in: query in: query
name: updatedAt name: updatedAt
type: string type: string
- in: query
name: uuid
type: string
produces: produces:
- application/json - application/json
responses: responses:
......
...@@ -17,6 +17,7 @@ type BrcLock struct { ...@@ -17,6 +17,7 @@ type BrcLock struct {
LockAddr string `json:"lockAddr" form:"lockAddr" gorm:"column:lock_addr;comment:;size:72;"` LockAddr string `json:"lockAddr" form:"lockAddr" gorm:"column:lock_addr;comment:;size:72;"`
Hash string `json:"hash" form:"hash" gorm:"column:hash;comment:;size:96;"` Hash string `json:"hash" form:"hash" gorm:"column:hash;comment:;size:96;"`
UnsignTx string `json:"unsignTx" form:"unsignTx" gorm:"column:unsign_tx;comment:;"` UnsignTx string `json:"unsignTx" form:"unsignTx" gorm:"column:unsign_tx;comment:;"`
Uuid string `json:"uuid" form:"uuid" gorm:"column:uuid;comment:;size:32;"`
} }
// TableName BrcLock 表名 // TableName BrcLock 表名
......
...@@ -32,9 +32,13 @@ type InscriptionTransferRequest struct { ...@@ -32,9 +32,13 @@ type InscriptionTransferRequest struct {
Amount uint64 `json:"amount"` // 转移数量 Amount uint64 `json:"amount"` // 转移数量
FeeRate uint64 `json:"feeRate"` // sat/byte FeeRate uint64 `json:"feeRate"` // sat/byte
UTXOs []string `json:"utxos"` // 铭文UTXO的txid:vout UTXOs []string `json:"utxos"` // 铭文UTXO的txid:vout
Period uint64 `json:"period"` // 锁定周期
StartTime uint64 `json:"startTime"` // 锁定时间
Uuid string `json:"uuid"`
} }
type PSBTResponse struct { type PSBTResponse struct {
Uuid string `json:"uuid"`
UnsignedPSBT string `json:"unsignedPSBT"` UnsignedPSBT string `json:"unsignedPSBT"`
UsedUTXOs []string `json:"usedUTXOs"` UsedUTXOs []string `json:"usedUTXOs"`
ChangeAmount int64 `json:"changeAmount"` // 找零金额 ChangeAmount int64 `json:"changeAmount"` // 找零金额
...@@ -47,3 +51,12 @@ type InscriptionUTXO struct { ...@@ -47,3 +51,12 @@ type InscriptionUTXO struct {
BTCAmt int64 `json:"btcAmt"` // 比特币金额(546聪) BTCAmt int64 `json:"btcAmt"` // 比特币金额(546聪)
Script string `json:"script"` // 铭文脚本 Script string `json:"script"` // 铭文脚本
} }
const (
LockStatusCommit = 0 // 提交
LockStatusHash = 1 // 上链
LockStatusHashSucc = 2 //上链成功质押中
LockStatusHashFail = 3 // 上链失败
LockStatusApplyUnLock = 4 // 申请解锁
LockStatusUnlock = 5 //解锁成功
)
...@@ -38,6 +38,16 @@ func (brcLockService *BrcLockService) UpdateBrcLock(brcLock brc.BrcLock) (err er ...@@ -38,6 +38,16 @@ func (brcLockService *BrcLockService) UpdateBrcLock(brcLock brc.BrcLock) (err er
return err return err
} }
func (brcLockService *BrcLockService) UpdateLockStatusByUuid(uuid string, status int) (err error) {
err = global.GVA_DB.Where("uuid = ?", uuid).UpdateColumn("status", status).Error
return err
}
func (brcLockService *BrcLockService) UpdateLockHashByUuid(uuid string, hash string) (err error) {
err = global.GVA_DB.Where("uuid = ?", uuid).UpdateColumn("hash", hash).Error
return err
}
// GetBrcLock 根据id获取BrcLock记录 // GetBrcLock 根据id获取BrcLock记录
// Author [piexlmax](https://github.com/piexlmax) // Author [piexlmax](https://github.com/piexlmax)
func (brcLockService *BrcLockService) GetBrcLock(id uint) (brcLock brc.BrcLock, err error) { func (brcLockService *BrcLockService) GetBrcLock(id uint) (brcLock brc.BrcLock, err error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment