1
This commit is contained in:
parent
2bb00c853c
commit
b41341a545
@ -13,6 +13,7 @@ class Market(object):
|
|||||||
'url': 'webapp/index.php?c=Market&a=getNonce',
|
'url': 'webapp/index.php?c=Market&a=getNonce',
|
||||||
'params': [
|
'params': [
|
||||||
['account', '', '钱包账号'],
|
['account', '', '钱包账号'],
|
||||||
|
['net_id', '', '网络id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
@ -26,8 +27,10 @@ class Market(object):
|
|||||||
'url': 'webapp/index.php?c=Market&a=auth',
|
'url': 'webapp/index.php?c=Market&a=auth',
|
||||||
'params': [
|
'params': [
|
||||||
['account', '', '钱包账号'],
|
['account', '', '钱包账号'],
|
||||||
['data', '', '待签名的原始数据(注意给的是完整的待签名数据),格式{name:"Auth", version: "1", nonce:"", signer:""}'],
|
['version', '', '版本号'],
|
||||||
|
['nonce', '', 'nonce'],
|
||||||
['signature', '', '签名'],
|
['signature', '', '签名'],
|
||||||
|
['net_id', '', '网络id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
|
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
|||||||
Subproject commit eeeac90264e4cd3d4de575d9ad504cacd85cb288
|
Subproject commit 996e3904f872001de8fd3080ba54607b09f3e824
|
@ -199,6 +199,13 @@ class MarketController extends BaseController {
|
|||||||
$signature = getReqVal('signature', '');
|
$signature = getReqVal('signature', '');
|
||||||
$gameId = 2006;
|
$gameId = 2006;
|
||||||
$funcId = 1;
|
$funcId = 1;
|
||||||
|
$this->buyBoxVerifySignature(
|
||||||
|
$buyerAddress,
|
||||||
|
$type,
|
||||||
|
$paymentTokenAddress,
|
||||||
|
$price,
|
||||||
|
$nonce,
|
||||||
|
$signature);
|
||||||
|
|
||||||
$batchIdx = 0;
|
$batchIdx = 0;
|
||||||
$idx = 0;
|
$idx = 0;
|
||||||
@ -404,4 +411,103 @@ class MarketController extends BaseController {
|
|||||||
return str_replace("\n", '\n', $str);
|
return str_replace("\n", '\n', $str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function buyBoxVerifySignature($buyerAddress,
|
||||||
|
$type,
|
||||||
|
$paymentTokenAddress,
|
||||||
|
$price,
|
||||||
|
$nonce,
|
||||||
|
$signature)
|
||||||
|
|
||||||
|
{
|
||||||
|
$params = array(
|
||||||
|
'c' => 'BcService',
|
||||||
|
'a' => 'buyBoxVerifySignature',
|
||||||
|
'type' => $type,
|
||||||
|
'paymentTokenAddress' => $paymentTokenAddress,
|
||||||
|
'price' => $price,
|
||||||
|
'nonce' => $nonce,
|
||||||
|
'signature' => $signature
|
||||||
|
);
|
||||||
|
$url = 'http://192.168.100.39:7671/webapp/index.php';
|
||||||
|
$response = '';
|
||||||
|
if (!phpcommon\HttpClient::get
|
||||||
|
($url,
|
||||||
|
$params,
|
||||||
|
$response)) {
|
||||||
|
phpcommon\sendError(500, 'server internal error');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error_log(json_encode(array(
|
||||||
|
'_REQUEST' => $_REQUEST,
|
||||||
|
'params' => $params,
|
||||||
|
'response' => $response
|
||||||
|
)));
|
||||||
|
$data = json_decode($response, true);
|
||||||
|
if (getXVal($data, 'errcode', 0) != 0) {
|
||||||
|
phpcommon\sendError(1, 'Signature verification failed');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
$recovered = getXVal($data, 'recovered', '');
|
||||||
|
if (!phpcommon\isSameAddress($recovered, $buyerAddress)) {
|
||||||
|
phpcommon\sendError(1, 'Signature verification failed');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNonce()
|
||||||
|
{
|
||||||
|
$nonce = myself()->_getNowTime();
|
||||||
|
myself()->_rspData(array(
|
||||||
|
'nonce' => $nonce
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function auth()
|
||||||
|
{
|
||||||
|
$version = getReqVal('version', '');
|
||||||
|
$nonce = getReqVal('nonce', '');
|
||||||
|
$signature = getReqVal('signature', '');
|
||||||
|
$params = array(
|
||||||
|
'c' => 'BcService',
|
||||||
|
'a' => 'authVerifySignature',
|
||||||
|
'version' => $version,
|
||||||
|
'nonce' => $nonce,
|
||||||
|
'signature' => $signature
|
||||||
|
);
|
||||||
|
$url = 'http://192.168.100.39:7671/webapp/index.php';
|
||||||
|
$response = '';
|
||||||
|
if (!phpcommon\HttpClient::get
|
||||||
|
($url,
|
||||||
|
$params,
|
||||||
|
$response)) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error_log(json_encode(array(
|
||||||
|
'_REQUEST' => $_REQUEST,
|
||||||
|
'params' => $params,
|
||||||
|
'response' => $response
|
||||||
|
)));
|
||||||
|
$data = json_decode($response, true);
|
||||||
|
if (getXVal($data, 'errcode', 0) != 0) {
|
||||||
|
myself()->_rspErr(1, 'Signature verification failed');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
$recovered = getXVal($data, 'recovered', '');
|
||||||
|
if (!phpcommon\isSameAddress($recovered, $buyerAddress)) {
|
||||||
|
myself()->_rspErr(1, 'Signature verification failed');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
myself()->_rspOk();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user