This commit is contained in:
jl777
2018-08-31 01:31:20 -11:00
parent 02da4225f4
commit 6862db0620

View File

@@ -253,7 +253,7 @@ std::string ChannelStop(uint64_t txfee,CPubKey destpub,uint256 origtxid)
return(""); return("");
} }
std::string ChannelPayment(uint64_t txfee,uint256 prevtxid,uint256 origtxid,int32_t numpayments,uint64_t amount) std::string ChannelPayment(uint64_t txfee,uint256 prevtxid,uint256 origtxid,int32_t n,uint64_t amount)
{ {
CMutableTransaction mtx; CPubKey mypk,destpub; struct CCcontract_info *cp,C; int32_t prevdepth; CMutableTransaction mtx; CPubKey mypk,destpub; struct CCcontract_info *cp,C; int32_t prevdepth;
// verify lasttxid and origtxid match and src is me // verify lasttxid and origtxid match and src is me
@@ -266,14 +266,14 @@ std::string ChannelPayment(uint64_t txfee,uint256 prevtxid,uint256 origtxid,int3
{ {
// add locked funds inputs // add locked funds inputs
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('P',mypk,destpub,prevdepth-depth,amount,secret))); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('P',mypk,destpub,prevdepth-n,amount,secret)));
} }
return(""); return("");
} }
std::string ChannelCollect(uint64_t txfee,uint256 paytxid,uint256 origtxid,int32_t n,uint64_t amount) std::string ChannelCollect(uint64_t txfee,uint256 paytxid,uint256 origtxid,int32_t n,uint64_t amount)
{ {
CMutableTransaction mtx; CPubKey mypk; struct CCcontract_info *cp,C; CMutableTransaction mtx; CPubKey mypk; struct CCcontract_info *cp,C; int32_t prevdepth;
// verify paytxid and origtxid match and dest is me // verify paytxid and origtxid match and dest is me
// also verify hashchain depth and amount // also verify hashchain depth and amount
cp = CCinit(&C,EVAL_CHANNELS); cp = CCinit(&C,EVAL_CHANNELS);
@@ -284,14 +284,15 @@ std::string ChannelCollect(uint64_t txfee,uint256 paytxid,uint256 origtxid,int32
{ {
// add locked funds inputs // add locked funds inputs
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',senderpub,mypk,prevdepth-depth,amount,paytxid))); mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('C',senderpub,mypk,prevdepth-n,amount,paytxid)));
} }
return(""); return("");
} }
std::string ChannelRefund(uint64_t txfee,uint256 stoptxid,uint256 origtxid) std::string ChannelRefund(uint64_t txfee,uint256 stoptxid,uint256 origtxid)
{ {
CMutableTransaction mtx; CPubKey mypk; struct CCcontract_info *cp,C; CMutableTransaction mtx; CPubKey mypk; struct CCcontract_info *cp,C; int64_t amount;
// verify stoptxid and origtxid match and are mine // verify stoptxid and origtxid match and are mine
cp = CCinit(&C,EVAL_CHANNELS); cp = CCinit(&C,EVAL_CHANNELS);
if ( txfee == 0 ) if ( txfee == 0 )
@@ -300,6 +301,7 @@ std::string ChannelRefund(uint64_t txfee,uint256 stoptxid,uint256 origtxid)
if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 ) if ( AddNormalinputs(mtx,mypk,2*txfee,1) > 0 )
{ {
mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk)); mtx.vout.push_back(MakeCC1vout(EVAL_CHANNELS,txfee,mypk));
mtx.vout.push_back(CTxOut(amount,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',mypk,mypk,0,0,stoptxid))); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeChannelsOpRet('R',mypk,mypk,0,0,stoptxid)));
} }
return(""); return("");
@@ -333,4 +335,3 @@ UniValue ChannelsInfo()
return(result); return(result);
} }
// ChannelPayment()