Small fixes

This commit is contained in:
Mihailo Milenkovic
2018-09-14 22:36:10 +02:00
parent 93cfcaa7ef
commit c2fa2759d6
5 changed files with 80 additions and 70 deletions

View File

@@ -5153,42 +5153,21 @@ UniValue channelsopen(const UniValue& params, bool fHelp)
return(result);
}
UniValue channelsstop(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); std::vector<unsigned char> destpub; struct CCcontract_info *cp,C; std::string hex; uint256 origtxid;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() != 2 )
throw runtime_error("channelsstop destpubkey origtxid\n");
if ( ensure_CCrequirements() < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
destpub = ParseHex(params[0].get_str().c_str());
origtxid = Parseuint256((char *)params[1].get_str().c_str());
hex = ChannelStop(0,pubkey2pk(destpub),origtxid);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt create channelsstop transaction");
return(result);
}
UniValue channelspayment(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 origtxid,prevtxid; int32_t n; int64_t amount;
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid,prevtxid; int32_t n; int64_t amount;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() != 4 )
throw runtime_error("channelspayment prevtxid origtxid n amount\n");
throw runtime_error("channelspayment opentxid prevtxid amount\n");
if ( ensure_CCrequirements() < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
prevtxid = Parseuint256((char *)params[0].get_str().c_str());
origtxid = Parseuint256((char *)params[1].get_str().c_str());
opentxid = Parseuint256((char *)params[0].get_str().c_str());
prevtxid = Parseuint256((char *)params[1].get_str().c_str());
n = atoi((char *)params[2].get_str().c_str());
amount = atoi((char *)params[3].get_str().c_str());
hex = ChannelPayment(0,prevtxid,origtxid,n,amount);
hex = ChannelPayment(0,opentxid,prevtxid,amount);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
@@ -5197,42 +5176,39 @@ UniValue channelspayment(const UniValue& params, bool fHelp)
return(result);
}
UniValue channelscollect(const UniValue& params, bool fHelp)
UniValue channelsclose(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 origtxid,paytxid; int32_t n; int64_t amount;
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() != 4 )
throw runtime_error("channelscollect paytxid origtxid n amount\n");
if ( fHelp || params.size() != 2 )
throw runtime_error("channelsclose opentxid\n");
if ( ensure_CCrequirements() < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
paytxid = Parseuint256((char *)params[0].get_str().c_str());
origtxid = Parseuint256((char *)params[1].get_str().c_str());
n = atoi((char *)params[2].get_str().c_str());
amount = atoi((char *)params[3].get_str().c_str());
hex = ChannelCollect(0,paytxid,origtxid,n,amount);
opentxid = Parseuint256((char *)params[1].get_str().c_str());
hex = ChannelClose(0,opentxid);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));
result.push_back(Pair("hex", hex));
} else ERR_RESULT("couldnt create channelscollect transaction");
} else ERR_RESULT("couldnt create channelsstop transaction");
return(result);
}
UniValue channelsrefund(const UniValue& params, bool fHelp)
{
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 origtxid,stoptxid;
UniValue result(UniValue::VOBJ); struct CCcontract_info *cp,C; std::string hex; uint256 opentxid,closetxid;
cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() != 2 )
throw runtime_error("channelsrefund stoptxid origtxid\n");
throw runtime_error("channelsrefund opentxid closetxid\n");
if ( ensure_CCrequirements() < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
const CKeyStore& keystore = *pwalletMain;
LOCK2(cs_main, pwalletMain->cs_wallet);
stoptxid = Parseuint256((char *)params[0].get_str().c_str());
origtxid = Parseuint256((char *)params[1].get_str().c_str());
hex = ChannelRefund(0,stoptxid,origtxid);
opentxid = Parseuint256((char *)params[0].get_str().c_str());
closetxid = Parseuint256((char *)params[1].get_str().c_str());
hex = ChannelRefund(0,opentxid,closetxid);
if ( hex.size() > 0 )
{
result.push_back(Pair("result", "success"));