Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
ffie-admin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
szh
ffie-admin
Commits
7db56002
Commit
7db56002
authored
Aug 01, 2025
by
szh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add brc job
parent
5489c408
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
12 deletions
+93
-12
brc_lock.go
server/api/v1/brc/brc_lock.go
+9
-10
blockchain.go
server/config/blockchain.go
+2
-0
brcCron.go
server/cron/brcCron.go
+77
-0
cron.go
server/cron/cron.go
+4
-1
blockcypher.go
server/initialize/blockcypher.go
+1
-1
No files found.
server/api/v1/brc/brc_lock.go
View file @
7db56002
...
...
@@ -10,7 +10,6 @@ import (
"ffie-admin/server/service"
"ffie-admin/server/utils"
"fmt"
"time"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/btcutil/psbt"
...
...
@@ -317,7 +316,7 @@ func BuildPSBT(params brcReq.CreateBrx20TxReq) (string, error) {
}}
// 3. 设置输出(铭文转移+找零)
receiverAddr
,
_
:=
btcutil
.
DecodeAddress
(
params
.
Receiver
,
&
chaincfg
.
TestNet3
Params
)
receiverAddr
,
_
:=
btcutil
.
DecodeAddress
(
params
.
Receiver
,
&
chaincfg
.
MainNet
Params
)
receiverScript
,
_
:=
txscript
.
PayToAddrScript
(
receiverAddr
)
buildInscriptionScript
,
_
:=
buildInscriptionScript
([]
byte
(
"hello"
))
packet
.
UnsignedTx
.
TxOut
=
append
(
packet
.
UnsignedTx
.
TxOut
,
...
...
@@ -400,8 +399,8 @@ func (brcLockApi *BrcLockApi) BuildBrc20Tx(c *gin.Context) {
"Amount"
:
{
utils
.
NotEmpty
()},
"UTXOs"
:
{
utils
.
NotEmpty
()},
"Period"
:
{
utils
.
NotEmpty
()},
"StartTime"
:
{
utils
.
NotEmpty
()},
"Uuid"
:
{
utils
.
NotEmpty
()},
//
"StartTime": {utils.NotEmpty()},
"Uuid"
:
{
utils
.
NotEmpty
()},
}
if
err
:=
utils
.
Verify
(
req
,
verify
);
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
...
...
@@ -415,13 +414,13 @@ func (brcLockApi *BrcLockApi) BuildBrc20Tx(c *gin.Context) {
}
psbtStr
.
Uuid
=
req
.
Uuid
period
:=
int
(
req
.
Period
)
startTime
:=
time
.
Unix
(
int64
(
req
.
StartTime
),
0
)
//
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
,
Period
:
&
period
,
LockAddr
:
req
.
ToAddress
,
Addr
:
req
.
FromAddress
,
//
StartTime: &startTime,
Uuid
:
req
.
Uuid
,
});
err
!=
nil
{
response
.
FailWithMessage
(
err
.
Error
(),
c
)
return
...
...
server/config/blockchain.go
View file @
7db56002
...
...
@@ -47,5 +47,7 @@ type BTCNode struct {
}
type
BlockCypher
struct
{
Coin
string
`mapstructure:"coin" json:"coin" yaml:"coin"`
Chain
string
`mapstructure:"chain" json:"chain" yaml:"chain"`
Token
string
`mapstructure:"token" json:"token" yaml:"token"`
}
server/cron/brcCron.go
0 → 100644
View file @
7db56002
package
cron
import
(
"ffie-admin/server/global"
"time"
"ffie-admin/server/model/brc"
brcReq
"ffie-admin/server/model/brc/request"
"github.com/blockcypher/gobcy/v2"
"go.uber.org/zap"
)
type
BrcLockJob
struct
{
JobName
string
Gobcy
gobcy
.
API
}
var
isJobRunning
=
false
func
(
b
BrcLockJob
)
Run
()
{
b
.
JobName
=
"BRCJOB"
if
isJobRunning
{
return
}
isJobRunning
=
true
defer
func
()
{
isJobRunning
=
false
}()
var
err
error
b
.
Gobcy
=
global
.
GVA_GOBCY
err
=
b
.
QueryLock
()
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"QueryLock err: "
,
zap
.
Error
(
err
))
}
global
.
GVA_LOG
.
Info
(
"BrcLockJob Run success"
)
}
func
(
b
BrcLockJob
)
QueryLock
()
error
{
var
err
error
var
lockList
[]
brc
.
BrcLock
err
=
global
.
GVA_DB
.
Model
(
&
brc
.
BrcLock
{})
.
Where
(
"status = ?"
,
brcReq
.
LockStatusHash
)
.
Find
(
&
lockList
)
.
Error
if
err
!=
nil
{
return
err
}
for
_
,
lock
:=
range
lockList
{
time
.
Sleep
(
time
.
Second
*
5
)
tx
,
err
:=
b
.
Gobcy
.
GetTX
(
lock
.
Hash
,
nil
)
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"GetTX err: "
,
zap
.
Error
(
err
))
continue
}
if
tx
.
BlockHeight
==
-
1
{
global
.
GVA_LOG
.
Error
(
"GetTX blockheight -1 unconfirmed: "
,
zap
.
Any
(
"height"
,
-
1
))
continue
}
if
tx
.
Confirmations
>=
6
{
st
:=
brcReq
.
LockStatusHashSucc
block
,
err
:=
b
.
Gobcy
.
GetBlock
(
tx
.
BlockHeight
,
""
,
nil
)
if
err
!=
nil
{
global
.
GVA_LOG
.
Error
(
"GetBlock err: "
,
zap
.
Error
(
err
))
continue
}
stime
:=
block
.
Time
lock
.
Status
=
&
st
lock
.
StartTime
=
&
stime
err
=
global
.
GVA_DB
.
Save
(
&
lock
)
.
Error
if
err
!=
nil
{
return
err
}
}
}
return
nil
}
server/cron/cron.go
View file @
7db56002
package
cron
import
"ffie-admin/server/global"
func
init
()
{
// var airDrop SendAirDropTx
// global.GVA_Timer.AddTaskByJob("SendAirDropRedPackage", "@every 60s", airDrop) // 发送空投红包
...
...
@@ -7,5 +9,6 @@ func init() {
// global.GVA_Timer.AddTaskByJob("SyncBlockJob", "@every 5s", syncBlock) // 同步evm委托交易相关数据
// var ticketDaily TicketDailyJob
// global.GVA_Timer.AddTaskByJob("TicketDailyJob", "@every 300s", ticketDaily) // 同步evm委托交易相关数据
var
brcLock
BrcLockJob
global
.
GVA_Timer
.
AddTaskByJob
(
"BrcLockJob"
,
"@every 10s"
,
brcLock
)
// 同步brc链上锁仓相关数据
}
server/initialize/blockcypher.go
View file @
7db56002
...
...
@@ -13,7 +13,7 @@ func BlockCypherInit() {
global
.
GVA_LOG
.
Warn
(
"未配置 BlockCypher token"
)
return
}
bc
:=
gobcy
.
API
{
Token
:
blockcypherConfig
.
Token
,
Coin
:
"btc"
,
Chain
:
"main"
}
bc
:=
gobcy
.
API
{
Token
:
blockcypherConfig
.
Token
,
Coin
:
blockcypherConfig
.
Coin
,
Chain
:
blockcypherConfig
.
Chain
}
global
.
GVA_GOBCY
=
bc
chainInfo
,
_
:=
bc
.
GetChain
()
global
.
GVA_LOG
.
Info
(
"btc"
,
zap
.
Any
(
"bc"
,
chainInfo
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment