Merge pull request #966 from letolabs/ccerrors

Add various error checking to gateway + oracle RPCs
This commit is contained in:
jl777
2018-11-20 21:48:24 -11:00
committed by GitHub
3 changed files with 31 additions and 7 deletions

View File

@@ -576,7 +576,8 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t
mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,gatewayspk));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysBindOpRet('B',coin,tokenid,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2)));
}
fprintf(stderr,"cant find enough inputs\n");
CCerror = strprintf("cant find enough inputs");
fprintf(stderr,"%s\n", CCerror.c_str() );
return("");
}
@@ -797,7 +798,8 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeAssetOpRet('t',assetid,zeroid,0,Mypubkey())));
}
}
fprintf(stderr,"cant find enough inputs or mismatched total\n");
CCerror = strprintf("cant find enough inputs or mismatched total");
fprintf(stderr,"%s\n", CCerror.c_str() );
return("");
}
@@ -836,7 +838,8 @@ std::string GatewaysWithdraw(uint64_t txfee,uint256 bindtxid,std::string refcoin
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret));
}
}
fprintf(stderr,"cant find enough inputs or mismatched total\n");
CCerror = strprintf("cant find enough inputs or mismatched total");
fprintf(stderr,"%s\n", CCerror.c_str() );
return("");
}

View File

@@ -794,12 +794,14 @@ std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector <uint8_t> da
mypk = pubkey2pk(Mypubkey());
if ( data.size() > 8192 )
{
fprintf(stderr,"datasize %d is too big\n",(int32_t)data.size());
CCerror = strprintf("datasize %d is too big",(int32_t)data.size());
fprintf(stderr,"%s\n", CCerror.c_str() );
return("");
}
if ( (datafee= OracleDatafee(pubKey,oracletxid,mypk)) <= 0 )
{
fprintf(stderr,"datafee %.8f is illegal\n",(double)datafee/COIN);
CCerror = strprintf("datafee %.8f is illegal",(double)datafee/COIN);
fprintf(stderr,"%s\n", CCerror.c_str() );
return("");
}
if ( txfee == 0 )
@@ -820,8 +822,14 @@ std::string OracleData(int64_t txfee,uint256 oracletxid,std::vector <uint8_t> da
mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,batonpk));
mtx.vout.push_back(CTxOut(datafee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeOraclesData('D',oracletxid,batontxid,mypk,data)));
} else fprintf(stderr,"couldnt find enough oracle inputs %s, limit 1 per utxo\n",coinaddr);
} else fprintf(stderr,"couldnt add normal inputs\n");
} else {
CCerror = strprintf("couldnt find enough oracle inputs %s, limit 1 per utxo\n",coinaddr);
fprintf(stderr,"%s\n", CCerror.c_str() );
}
} else {
CCerror = strprintf("couldnt add normal inputs\n");
fprintf(stderr,"%s\n", CCerror.c_str() );
}
return("");
}