rename data -> contract_terms
This commit is contained in:
parent
09c7be80fd
commit
894a09a51c
@ -213,27 +213,16 @@ async function downloadContract(url: string, nonce: string): Promise<any> {
|
|||||||
|
|
||||||
async function processProposal(proposal: any) {
|
async function processProposal(proposal: any) {
|
||||||
|
|
||||||
if (!proposal.data) {
|
if (!proposal.contract_terms) {
|
||||||
console.error("field proposal.data field missing");
|
console.error("field proposal.contract_terms field missing");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!proposal.hash) {
|
const contractHash = await wxApi.hashContract(proposal.contract_terms);
|
||||||
console.error("proposal.hash field missing");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const contractHash = await wxApi.hashContract(proposal.data);
|
|
||||||
|
|
||||||
if (contractHash !== proposal.hash) {
|
|
||||||
console.error(`merchant-supplied contract hash is wrong (us: ${contractHash}, merchant: ${proposal.hash})`);
|
|
||||||
console.dir(proposal.data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const proposalId = await wxApi.saveProposal({
|
const proposalId = await wxApi.saveProposal({
|
||||||
contractTerms: proposal.data,
|
contractTerms: proposal.contract_terms,
|
||||||
contractTermsHash: proposal.hash,
|
contractTermsHash: contractHash,
|
||||||
merchantSig: proposal.sig,
|
merchantSig: proposal.sig,
|
||||||
timestamp: (new Date()).getTime(),
|
timestamp: (new Date()).getTime(),
|
||||||
});
|
});
|
||||||
@ -375,7 +364,7 @@ function talerPay(msg: any): Promise<any> {
|
|||||||
if (msg.contract_url) {
|
if (msg.contract_url) {
|
||||||
const nonce = await wxApi.generateNonce();
|
const nonce = await wxApi.generateNonce();
|
||||||
const proposal = await downloadContract(msg.contract_url, nonce);
|
const proposal = await downloadContract(msg.contract_url, nonce);
|
||||||
if (proposal.data.nonce !== nonce) {
|
if (proposal.contract_terms.nonce !== nonce) {
|
||||||
console.error("stale contract");
|
console.error("stale contract");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user