Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
token
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wallet
token
Commits
aa04ceeb
Commit
aa04ceeb
authored
Aug 27, 2019
by
shajiaiming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现跨链自动交易
parent
b71d7bf7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
39 deletions
+43
-39
CrossChainController.php
api/controllers/CrossChainController.php
+1
-0
CrossChainController.php
console/controllers/CrossChainController.php
+42
-39
No files found.
api/controllers/CrossChainController.php
View file @
aa04ceeb
...
@@ -47,6 +47,7 @@ class CrossChainController extends BaseController
...
@@ -47,6 +47,7 @@ class CrossChainController extends BaseController
}
else
if
(
3
==
$val
[
'step'
])
{
}
else
if
(
3
==
$val
[
'step'
])
{
$seq
=
'thrid'
;
$seq
=
'thrid'
;
}
else
{
}
else
{
$seq
=
'first'
;
}
}
$data
[
'txhex_'
.
$seq
]
=
$val
[
'tx'
];
$data
[
'txhex_'
.
$seq
]
=
$val
[
'tx'
];
...
...
console/controllers/CrossChainController.php
View file @
aa04ceeb
...
@@ -21,50 +21,53 @@ class CrossChainController extends Controller
...
@@ -21,50 +21,53 @@ class CrossChainController extends Controller
echo
date
(
'Y-m-d H:i:s'
)
.
'暂无跨链交易计划'
.
PHP_EOL
;
echo
date
(
'Y-m-d H:i:s'
)
.
'暂无跨链交易计划'
.
PHP_EOL
;
return
0
;
return
0
;
}
}
foreach
(
$model
as
$key
=>
$val
)
{
go
(
function
()
use
(
$val
)
{
\Co
::
sleep
(
0.5
);
if
(
1
==
$val
[
'step'
])
{
$seq
=
'first'
;
}
else
if
(
2
==
$val
[
'step'
])
{
$seq
=
'second'
;
}
else
if
(
3
==
$val
[
'step'
])
{
$seq
=
'thrid'
;
}
else
{
}
foreach
(
$model
as
$val
)
{
// go(function () use ($val) {
// \Co::sleep(0.5);
if
(
1
==
$val
[
'current_step'
])
{
$seq
=
'first'
;
$step
=
1
;
}
else
if
(
2
==
$val
[
'current_step'
])
{
$seq
=
'second'
;
$step
=
2
;
}
else
if
(
3
==
$val
[
'current_step'
])
{
$seq
=
'thrid'
;
$step
=
3
;
}
else
{
$seq
=
'first'
;
$step
=
1
;
}
$node_params
=
$val
[
'transfer_url_'
.
$seq
];
$node_params
=
$val
[
'transfer_url_'
.
$seq
];
$node_params
=
explode
(
':'
,
$node_params
);
$node_params
=
[
'scheme'
=>
$node_params
[
0
],
'host'
=>
str_replace
(
'//'
,
''
,
$node_params
[
1
]),
'port'
=>
$node_params
[
2
]
];
$service
=
new
Chain33Service
(
$node_params
);
$sign_str
=
$val
[
'txhex_'
.
$seq
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
$node_params
=
Yii
::
$app
->
params
[
'chain_parallel'
][
'wasm'
][
$val
[
'coin_name'
]
.
'_wallet'
];
if
(
0
!=
$result
[
'code'
])
{
$service
=
new
Chain33Service
(
$node_params
);
$txhash
=
'0'
;
$msg
=
$result
[
'msg'
];
goto
doEnd
;
}
$txhash
=
$result
[
'result'
];
$msg
=
'success'
;
$step
=
(
$step
+
1
>
3
)
?
3
:
(
$step
+
1
);
$txHex
=
$val
[
'txhex_'
.
$seq
];
doEnd
:
$privkey
=
'72c3879f1f9b523f266a9545b69bd41c0251483a93e21e348e85118afe17a5e21'
;
$current_step
=
$step
;
$expire
=
'1m'
;
$currentModel
=
CoinCrossChain
::
findOne
(
$val
[
'id'
]);
$currentModel
->
current_step
=
$current_step
;
$currentModel
->
txhash
=
$txhash
;
$currentModel
->
msg
=
$msg
;
$currentModel
->
save
();
$signRawTx
=
$service
->
signRawTx
(
$privkey
,
$txHex
,
$expire
);
// });
if
(
0
!=
$signRawTx
[
'code'
])
{
$txhash
=
'0'
;
$msg
=
$signRawTx
[
'msg'
];
goto
doEnd
;
}
$sign_str
=
$signRawTx
[
'result'
];
$result
=
$service
->
sendTransaction
(
$sign_str
);
if
(
0
!=
$result
[
'code'
])
{
$txhash
=
'0'
;
$msg
=
$result
[
'msg'
];
goto
doEnd
;
}
$txhash
=
$result
[
'result'
];
$msg
=
'success'
;
doEnd
:
$currentModel
=
CoinAirDropTransfer
::
findOne
(
$id
);
$currentModel
->
txhash
=
$txhash
;
$currentModel
->
msg
=
$msg
;
$currentModel
->
save
();
});
}
}
return
0
;
return
0
;
}
}
...
...
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