Code link: https://github.com/MultiChain/smart-filter-examples/blob/master/transaction-filters/approve-asset-transfer.js
Error:
Filter code blocked this transaction with the reason: (time taken 0.001472 seconds)
Address 1KB85GgVgHyters6tMMeQ7DYS9fkY192yq8ey1V did not include sufficient USD spending approvals in this transaction false undefined
I'm trying to understand GitHub transaction filter example- approve asset transfer.
If I have understood it correctly, that code is processing an only pre-approved transaction. pre-approved transactions are those whom approvals are given by the address with low-1 permissions. And that approvals are provided by the command:
sendfrom <approver-address> <approvee-address> {"data":{"json":{"type":"approval","maxraw":<rawqty>,"expiry":<expiry>}}}
So I gave approvals using the above command and I set max raw quantity and expiry as last block time. And then I tried to run this code. But still, I'm getting the above error. To identify that my approval is set properly, I'm checking variable like
for (var inputnum=0; inputnum<tx.vin.length; inputnum++) {
var spentoutput=getfiltertxinput(inputnum);
if (
outputisapproval(spentoutput) &&
(spentoutput.scriptPubKey.addresses[0]==address)&&
(spentoutput.data[0].json.expiry >= getlastblockinfo().time)
) {
requiredraw-=spentoutput.data[0].json.maxraw; /* we can use this approval */
}
}
if (requiredraw>0)
return "Address "+address+" did not include sufficient USD spending approvals in this transaction "+hasapproval+" "+spentoutput.data;
}
}
}
why spentoutput.data is returned as undefined even when I have given approvals:
command:
sendfrom 1KB85GgVgHyters6tMMeQ7DYS9fkY192yq8ey1V 192ruBtNjWSXUQi2xpWmka5M14rUbNNxzxTbcb '{"data":{"json":{"type":"approval","maxraw":10000000,"expiry":1584258634}}}'
Please resolve my doubt asap.