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
0687e53b
Commit
0687e53b
authored
6 years ago
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交易确认
parent
32741b93
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
17 deletions
+28
-17
Brower.php
common/service/brower/Brower.php
+6
-5
BtcBrower.php
common/service/brower/BtcBrower.php
+5
-1
BtyBrower.php
common/service/brower/BtyBrower.php
+2
-2
DcrBrower.php
common/service/brower/DcrBrower.php
+1
-1
EthBrower.php
common/service/brower/EthBrower.php
+14
-8
No files found.
common/service/brower/Brower.php
View file @
0687e53b
...
...
@@ -11,8 +11,8 @@ namespace common\service\brower;
class
Brower
implements
BrowerInterface
{
const
TRANS_OK
=
1
;
//交易成功
const
TRANS_FAIL
=
2
;
//交易失败
const
TRANS_PADDING
=
3
;
//交易状态未知
const
TRANS_FAIL
=
-
1
;
//交易失败
const
TRANS_PADDING
=
0
;
//交易状态未知
const
ERROR
=
4
;
//接口返回错误
public
static
$msg
=
[
self
::
TRANS_OK
=>
'SUCCEED'
,
...
...
@@ -26,11 +26,11 @@ class Brower implements BrowerInterface
return
[
'code'
=>
self
::
ERROR
,
'msg'
=>
'Coin not supported!'
];
}
public
function
StatusReturn
(
$code
,
$msg
=
''
)
public
function
StatusReturn
(
$code
,
$msg
=
''
,
$data
=
[]
)
{
if
(
$msg
)
{
return
[
'code'
=>
$code
,
'msg'
=>
$msg
];
return
[
'code'
=>
$code
,
'msg'
=>
$msg
,
'data'
=>
$data
];
}
return
[
'code'
=>
$code
,
'msg'
=>
self
::
$msg
[
$code
]];
return
[
'code'
=>
$code
,
'msg'
=>
self
::
$msg
[
$code
]
,
'data'
=>
$data
];
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
common/service/brower/BtcBrower.php
View file @
0687e53b
...
...
@@ -22,7 +22,11 @@ class BtcBrower extends Brower
if
(
$content
[
'err_no'
])
{
return
$this
->
StatusReturn
(
self
::
ERROR
,
$content
[
'err_msg'
]);
}
return
$this
->
StatusReturn
(
self
::
TRANS_OK
);
if
(
$content
[
'data'
][
'confirmations'
]
>
0
)
{
return
$this
->
StatusReturn
(
self
::
TRANS_OK
,
''
,
[
'height'
=>
$content
[
'data'
][
'block_height'
],
'blocktime'
=>
$content
[
'data'
][
'block_time'
]]);
}
else
{
return
$this
->
StatusReturn
(
self
::
TRANS_PADDING
);
}
}
return
$this
->
StatusReturn
(
self
::
ERROR
);
}
...
...
This diff is collapsed.
Click to expand it.
common/service/brower/BtyBrower.php
View file @
0687e53b
...
...
@@ -26,10 +26,10 @@ class BtyBrower extends Brower
];
$post
=
json_encode
(
$post
);
$ch
->
setOption
(
CURLOPT_POSTFIELDS
,
$post
);
$result
=
$ch
->
post
(
$this
->
base_uri
,
false
);
$result
=
$ch
->
post
(
$this
->
base_uri
,
false
);
// from, height
if
(
$result
)
{
if
(
$result
[
'result'
])
{
return
$this
->
StatusReturn
(
self
::
TRANS_OK
);
return
$this
->
StatusReturn
(
self
::
TRANS_OK
,
''
,
[
'height'
=>
$result
[
'result'
][
'height'
]]
);
}
elseif
(
$result
[
'error'
])
{
return
$this
->
StatusReturn
(
self
::
ERROR
,
$result
[
'error'
]);
}
...
...
This diff is collapsed.
Click to expand it.
common/service/brower/DcrBrower.php
View file @
0687e53b
...
...
@@ -22,7 +22,7 @@ class DcrBrower extends Brower
$result
=
json_decode
(
$content
,
true
);
if
(
$result
)
{
if
(
isset
(
$result
[
'confirmations'
])
&&
$result
[
'confirmations'
]
>
0
)
{
return
$this
->
StatusReturn
(
self
::
TRANS_OK
);
return
$this
->
StatusReturn
(
self
::
TRANS_OK
,
''
,
[
'height'
=>
$result
[
'blockheight'
],
'blocktime'
=>
$result
[
'blocktime'
]]
);
}
else
{
return
$this
->
StatusReturn
(
self
::
TRANS_PADDING
);
}
...
...
This diff is collapsed.
Click to expand it.
common/service/brower/EthBrower.php
View file @
0687e53b
...
...
@@ -12,20 +12,25 @@ use common\helpers\Curl;
class
EthBrower
extends
Brower
{
private
$base_uri
=
'https://
etherscan.io/
'
;
private
$base_uri
=
'https://
api.etherscan.io/api?module=transaction&action=gettxreceiptstatus&txhash=
'
;
public
function
getStatus
(
string
$txhash
)
{
$uri
=
$this
->
base_uri
.
'tx/'
.
$txhash
;
$uri
=
$this
->
base_uri
.
$txhash
;
$ch
=
new
Curl
();
$content
=
$ch
->
get
(
$uri
,
tru
e
);
if
(
$content
)
{
if
(
strpos
(
$content
,
'Success'
)
!==
false
)
{
return
$this
->
StatusReturn
(
self
::
TRANS_OK
)
;
}
elseif
(
strpos
(
$content
,
'Fail'
)
!==
false
)
{
$content
=
$ch
->
get
(
$uri
,
fals
e
);
if
(
$content
&&
is_array
(
$content
)
)
{
if
(
1
==
$content
[
'status'
]
)
{
$status
=
$content
[
'result'
][
'status'
]
;
if
(
0
==
$status
)
{
return
$this
->
StatusReturn
(
self
::
TRANS_FAIL
);
}
elseif
(
1
==
$status
)
{
return
$this
->
StatusReturn
(
self
::
TRANS_OK
);
}
else
{
return
$this
->
StatusReturn
(
self
::
TRANS_PADDING
);
}
}
}
return
$this
->
StatusReturn
(
self
::
ERROR
,
'txHash not exists'
);
return
$this
->
StatusReturn
(
self
::
ERROR
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
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