fix two bugs for Alright
This commit is contained in:
@@ -149,8 +149,12 @@ bool IsCCInput(CScript const& scriptSig)
|
|||||||
|
|
||||||
bool CheckTxFee(const CTransaction &tx, uint64_t txfee, uint32_t height, uint64_t blocktime)
|
bool CheckTxFee(const CTransaction &tx, uint64_t txfee, uint32_t height, uint64_t blocktime)
|
||||||
{
|
{
|
||||||
|
LOCK(mempool.cs);
|
||||||
|
CCoinsView dummy;
|
||||||
|
CCoinsViewCache view(&dummy);
|
||||||
int64_t interest; uint64_t valuein;
|
int64_t interest; uint64_t valuein;
|
||||||
CCoinsViewCache &view = *pcoinsTip;
|
CCoinsViewMemPool viewMemPool(pcoinsTip, mempool);
|
||||||
|
view.SetBackend(viewMemPool);
|
||||||
valuein = view.GetValueIn(height,&interest,tx,blocktime);
|
valuein = view.GetValueIn(height,&interest,tx,blocktime);
|
||||||
if ( valuein-tx.GetValueOut() > txfee )
|
if ( valuein-tx.GetValueOut() > txfee )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -199,11 +199,10 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
|
|||||||
{
|
{
|
||||||
if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 )
|
if ( lockedblocks < 0 || minrelease < 0 || totalallocations <= 0 || txidoprets.size() < 2 )
|
||||||
return(eval->Invalid("negative values"));
|
return(eval->Invalid("negative values"));
|
||||||
if ( !CheckTxFee(tx, PAYMENTS_TXFEE, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) )
|
|
||||||
return eval->Invalid("txfee is too high");
|
|
||||||
Paymentspk = GetUnspendable(cp,0);
|
Paymentspk = GetUnspendable(cp,0);
|
||||||
//fprintf(stderr, "lockedblocks.%i minrelease.%i totalallocations.%i txidopret1.%s txidopret2.%s\n",lockedblocks, minrelease, totalallocations, txidoprets[0].ToString().c_str(), txidoprets[1].ToString().c_str() );
|
//fprintf(stderr, "lockedblocks.%i minrelease.%i totalallocations.%i txidopret1.%s txidopret2.%s\n",lockedblocks, minrelease, totalallocations, txidoprets[0].ToString().c_str(), txidoprets[1].ToString().c_str() );
|
||||||
|
if ( !CheckTxFee(tx, PAYMENTS_TXFEE+1, chainActive.LastTip()->GetHeight(), chainActive.LastTip()->nTime) )
|
||||||
|
return eval->Invalid("txfee is too high");
|
||||||
// Get all the script pubkeys and allocations
|
// Get all the script pubkeys and allocations
|
||||||
std::vector<int64_t> allocations;
|
std::vector<int64_t> allocations;
|
||||||
std::vector<CScript> scriptPubKeys;
|
std::vector<CScript> scriptPubKeys;
|
||||||
@@ -267,7 +266,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
|
|||||||
int64_t test = allocations[n];
|
int64_t test = allocations[n];
|
||||||
test *= checkamount;
|
test *= checkamount;
|
||||||
test /= totalallocations;
|
test /= totalallocations;
|
||||||
if ( test != tx.vout[i].nValue )
|
if ( test != tx.vout[i].nValue && test != tx.vout[i].nValue-1 )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "vout.%i test.%li vs nVlaue.%li\n",i, test, tx.vout[i].nValue);
|
fprintf(stderr, "vout.%i test.%li vs nVlaue.%li\n",i, test, tx.vout[i].nValue);
|
||||||
return(eval->Invalid("amounts do not match"));
|
return(eval->Invalid("amounts do not match"));
|
||||||
|
|||||||
Reference in New Issue
Block a user