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
Aug 01, 2018
by
rlgy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
交易确认
parent
32741b93
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
18 deletions
+29
-18
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
+15
-9
No files found.
common/service/brower/Brower.php
View file @
0687e53b
...
@@ -11,8 +11,8 @@ namespace common\service\brower;
...
@@ -11,8 +11,8 @@ namespace common\service\brower;
class
Brower
implements
BrowerInterface
class
Brower
implements
BrowerInterface
{
{
const
TRANS_OK
=
1
;
//交易成功
const
TRANS_OK
=
1
;
//交易成功
const
TRANS_FAIL
=
2
;
//交易失败
const
TRANS_FAIL
=
-
1
;
//交易失败
const
TRANS_PADDING
=
3
;
//交易状态未知
const
TRANS_PADDING
=
0
;
//交易状态未知
const
ERROR
=
4
;
//接口返回错误
const
ERROR
=
4
;
//接口返回错误
public
static
$msg
=
[
public
static
$msg
=
[
self
::
TRANS_OK
=>
'SUCCEED'
,
self
::
TRANS_OK
=>
'SUCCEED'
,
...
@@ -26,11 +26,11 @@ class Brower implements BrowerInterface
...
@@ -26,11 +26,11 @@ class Brower implements BrowerInterface
return
[
'code'
=>
self
::
ERROR
,
'msg'
=>
'Coin not supported!'
];
return
[
'code'
=>
self
::
ERROR
,
'msg'
=>
'Coin not supported!'
];
}
}
public
function
StatusReturn
(
$code
,
$msg
=
''
)
public
function
StatusReturn
(
$code
,
$msg
=
''
,
$data
=
[]
)
{
{
if
(
$msg
)
{
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
common/service/brower/BtcBrower.php
View file @
0687e53b
...
@@ -22,7 +22,11 @@ class BtcBrower extends Brower
...
@@ -22,7 +22,11 @@ class BtcBrower extends Brower
if
(
$content
[
'err_no'
])
{
if
(
$content
[
'err_no'
])
{
return
$this
->
StatusReturn
(
self
::
ERROR
,
$content
[
'err_msg'
]);
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
);
return
$this
->
StatusReturn
(
self
::
ERROR
);
}
}
...
...
common/service/brower/BtyBrower.php
View file @
0687e53b
...
@@ -26,10 +26,10 @@ class BtyBrower extends Brower
...
@@ -26,10 +26,10 @@ class BtyBrower extends Brower
];
];
$post
=
json_encode
(
$post
);
$post
=
json_encode
(
$post
);
$ch
->
setOption
(
CURLOPT_POSTFIELDS
,
$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
)
{
if
(
$result
[
'result'
])
{
if
(
$result
[
'result'
])
{
return
$this
->
StatusReturn
(
self
::
TRANS_OK
);
return
$this
->
StatusReturn
(
self
::
TRANS_OK
,
''
,
[
'height'
=>
$result
[
'result'
][
'height'
]]
);
}
elseif
(
$result
[
'error'
])
{
}
elseif
(
$result
[
'error'
])
{
return
$this
->
StatusReturn
(
self
::
ERROR
,
$result
[
'error'
]);
return
$this
->
StatusReturn
(
self
::
ERROR
,
$result
[
'error'
]);
}
}
...
...
common/service/brower/DcrBrower.php
View file @
0687e53b
...
@@ -22,7 +22,7 @@ class DcrBrower extends Brower
...
@@ -22,7 +22,7 @@ class DcrBrower extends Brower
$result
=
json_decode
(
$content
,
true
);
$result
=
json_decode
(
$content
,
true
);
if
(
$result
)
{
if
(
$result
)
{
if
(
isset
(
$result
[
'confirmations'
])
&&
$result
[
'confirmations'
]
>
0
)
{
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
{
}
else
{
return
$this
->
StatusReturn
(
self
::
TRANS_PADDING
);
return
$this
->
StatusReturn
(
self
::
TRANS_PADDING
);
}
}
...
...
common/service/brower/EthBrower.php
View file @
0687e53b
...
@@ -12,20 +12,25 @@ use common\helpers\Curl;
...
@@ -12,20 +12,25 @@ use common\helpers\Curl;
class
EthBrower
extends
Brower
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
)
public
function
getStatus
(
string
$txhash
)
{
{
$uri
=
$this
->
base_uri
.
'tx/'
.
$txhash
;
$uri
=
$this
->
base_uri
.
$txhash
;
$ch
=
new
Curl
();
$ch
=
new
Curl
();
$content
=
$ch
->
get
(
$uri
,
true
);
$content
=
$ch
->
get
(
$uri
,
false
);
if
(
$content
)
{
if
(
$content
&&
is_array
(
$content
))
{
if
(
strpos
(
$content
,
'Success'
)
!==
false
)
{
if
(
1
==
$content
[
'status'
])
{
return
$this
->
StatusReturn
(
self
::
TRANS_OK
);
$status
=
$content
[
'result'
][
'status'
];
}
elseif
(
strpos
(
$content
,
'Fail'
)
!==
false
)
{
if
(
0
==
$status
)
{
return
$this
->
StatusReturn
(
self
::
TRANS_FAIL
);
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
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