remove mutually exclusive constraint on selfimport
-ac_beam and -ac_coda cannot be active at the same time Clusters can do import coin normally even with self-import chains. -ac_import=KMD (any bitcoinprotocol coin) will make a side chain (not implemented yet) Theoretically -ac_beam or -ac_coda can work with side chain (not implemented yet other than chain params)
This commit is contained in:
@@ -33,17 +33,23 @@ extern std::string ASSETCHAINS_SELFIMPORT;
|
|||||||
extern uint16_t ASSETCHAINS_CODAPORT,ASSETCHAINS_BEAMPORT;
|
extern uint16_t ASSETCHAINS_CODAPORT,ASSETCHAINS_BEAMPORT;
|
||||||
extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
extern uint8_t ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
||||||
|
|
||||||
int32_t GetSelfimportProof(CMutableTransaction &mtx,CScript &scriptPubKey,TxProof &proof,uint64_t burnAmount,std::vector<uint8_t> rawtx,uint256 txid,std::vector<uint8_t> rawproof) // find burnTx with hash from "other" daemon
|
int32_t GetSelfimportProof(std::string source,CMutableTransaction &mtx,CScript &scriptPubKey,TxProof &proof,uint64_t burnAmount,std::vector<uint8_t> rawtx,uint256 txid,std::vector<uint8_t> &rawproof) // find burnTx with hash from "other" daemon
|
||||||
{
|
{
|
||||||
MerkleBranch newBranch; CMutableTransaction tmpmtx; CTransaction tx,vintx; uint256 blockHash; char destaddr[64],pkaddr[64];
|
MerkleBranch newBranch; CMutableTransaction tmpmtx; CTransaction tx,vintx; uint256 blockHash; char destaddr[64],pkaddr[64];
|
||||||
tmpmtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),komodo_nextheight());
|
tmpmtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(),komodo_nextheight());
|
||||||
if ( ASSETCHAINS_SELFIMPORT == "BEAM" )
|
if ( source == "BEAM" )
|
||||||
{
|
{
|
||||||
|
if ( ASSETCHAINS_BEAMPORT == 0 )
|
||||||
|
return(-1);
|
||||||
// confirm via ASSETCHAINS_BEAMPORT that burnTx/hash is a valid BEAM burn
|
// confirm via ASSETCHAINS_BEAMPORT that burnTx/hash is a valid BEAM burn
|
||||||
|
// return(0);
|
||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_SELFIMPORT == "CODA" )
|
else if ( source == "CODA" )
|
||||||
{
|
{
|
||||||
|
if ( ASSETCHAINS_CODAPORT == 0 )
|
||||||
|
return(-1);
|
||||||
// confirm via ASSETCHAINS_CODAPORT that burnTx/hash is a valid CODA burn
|
// confirm via ASSETCHAINS_CODAPORT that burnTx/hash is a valid CODA burn
|
||||||
|
// return(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -61,7 +67,7 @@ int32_t GetSelfimportProof(CMutableTransaction &mtx,CScript &scriptPubKey,TxProo
|
|||||||
mtx.vout[0].scriptPubKey = scriptPubKey;
|
mtx.vout[0].scriptPubKey = scriptPubKey;
|
||||||
if ( tx.GetHash() != txid )
|
if ( tx.GetHash() != txid )
|
||||||
return(-1);
|
return(-1);
|
||||||
if ( ASSETCHAINS_SELFIMPORT == "PUBKEY" )
|
if ( source == "PUBKEY" )
|
||||||
{
|
{
|
||||||
// make sure vin0 is signed by ASSETCHAINS_OVERRIDE_PUBKEY33
|
// make sure vin0 is signed by ASSETCHAINS_OVERRIDE_PUBKEY33
|
||||||
if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,blockHash) == 0 )
|
if ( myGetTransaction(tx.vin[0].prevout.hash,vintx,blockHash) == 0 )
|
||||||
@@ -77,9 +83,9 @@ int32_t GetSelfimportProof(CMutableTransaction &mtx,CScript &scriptPubKey,TxProo
|
|||||||
fprintf(stderr,"mismatched vin0[%d] -> %s vs %s\n",tx.vin[0].prevout.n,destaddr,pkaddr);
|
fprintf(stderr,"mismatched vin0[%d] -> %s vs %s\n",tx.vin[0].prevout.n,destaddr,pkaddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if ( source == ASSETCHAINS_SELFIMPORT )
|
||||||
{
|
{
|
||||||
// ASSETCHAINS_SELFIMPORT and external coin is the assetchains symbol in the burnTx OP_RETURN
|
// source is external coin is the assetchains symbol in the burnTx OP_RETURN
|
||||||
// burnAmount, rawtx and rawproof should be enough for gatewaysdeposit equivalent
|
// burnAmount, rawtx and rawproof should be enough for gatewaysdeposit equivalent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -88,25 +94,26 @@ int32_t GetSelfimportProof(CMutableTransaction &mtx,CScript &scriptPubKey,TxProo
|
|||||||
|
|
||||||
// use proof from the above functions to validate the import
|
// use proof from the above functions to validate the import
|
||||||
|
|
||||||
int32_t CheckBEAMimport(TxProof proof,CTransaction burnTx,std::vector<CTxOut> payouts)
|
int32_t CheckBEAMimport(TxProof proof,std::vector<uint8_t> rawproof,CTransaction burnTx,std::vector<CTxOut> payouts)
|
||||||
{
|
{
|
||||||
// check with dual-BEAM daemon via ASSETCHAINS_BEAMPORT for validity of burnTx
|
// check with dual-BEAM daemon via ASSETCHAINS_BEAMPORT for validity of burnTx
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CheckCODAimport(TxProof proof,CTransaction burnTx,std::vector<CTxOut> payouts)
|
int32_t CheckCODAimport(TxProof proof,std::vector<uint8_t> rawproof,CTransaction burnTx,std::vector<CTxOut> payouts)
|
||||||
{
|
{
|
||||||
// check with dual-CODA daemon via ASSETCHAINS_CODAPORT for validity of burnTx
|
// check with dual-CODA daemon via ASSETCHAINS_CODAPORT for validity of burnTx
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CheckGATEWAYimport(std::string coin,TxProof proof,CTransaction burnTx,std::vector<CTxOut> payouts)
|
int32_t CheckGATEWAYimport(TxProof proof,std::vector<uint8_t> rawproof,CTransaction burnTx,std::vector<CTxOut> payouts)
|
||||||
{
|
{
|
||||||
|
// ASSETCHAINS_SELFIMPORT is coin
|
||||||
// check for valid burn from external coin blockchain and if valid return(0);
|
// check for valid burn from external coin blockchain and if valid return(0);
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CheckPUBKEYimport(TxProof proof,CTransaction burnTx,std::vector<CTxOut> payouts)
|
int32_t CheckPUBKEYimport(TxProof proof,std::vector<uint8_t> rawproof,CTransaction burnTx,std::vector<CTxOut> payouts)
|
||||||
{
|
{
|
||||||
// if burnTx has ASSETCHAINS_PUBKEY vin, it is valid return(0);
|
// if burnTx has ASSETCHAINS_PUBKEY vin, it is valid return(0);
|
||||||
fprintf(stderr,"proof txid.%s\n",proof.first.GetHex().c_str());
|
fprintf(stderr,"proof txid.%s\n",proof.first.GetHex().c_str());
|
||||||
@@ -117,19 +124,18 @@ int32_t CheckPUBKEYimport(TxProof proof,CTransaction burnTx,std::vector<CTxOut>
|
|||||||
bool Eval::ImportCoin(const std::vector<uint8_t> params,const CTransaction &importTx,unsigned int nIn)
|
bool Eval::ImportCoin(const std::vector<uint8_t> params,const CTransaction &importTx,unsigned int nIn)
|
||||||
{
|
{
|
||||||
TxProof proof; CTransaction burnTx; std::vector<CTxOut> payouts; uint64_t txfee = 10000;
|
TxProof proof; CTransaction burnTx; std::vector<CTxOut> payouts; uint64_t txfee = 10000;
|
||||||
uint32_t targetCcid; std::string targetSymbol; uint256 payoutsHash;
|
uint32_t targetCcid; std::string targetSymbol; uint256 payoutsHash; std::vector<uint8_t> rawproof;
|
||||||
if (importTx.vout.size() < 2)
|
if ( importTx.vout.size() < 2 )
|
||||||
return Invalid("too-few-vouts");
|
return Invalid("too-few-vouts");
|
||||||
// params
|
// params
|
||||||
if (!UnmarshalImportTx(importTx, proof, burnTx, payouts))
|
if (!UnmarshalImportTx(importTx, proof, burnTx, payouts))
|
||||||
return Invalid("invalid-params");
|
return Invalid("invalid-params");
|
||||||
|
|
||||||
// Control all aspects of this transaction
|
// Control all aspects of this transaction
|
||||||
// It should not be at all malleable
|
// It should not be at all malleable
|
||||||
if (MakeImportCoinTransaction(proof, burnTx, payouts).GetHash() != importTx.GetHash())
|
if (MakeImportCoinTransaction(proof, burnTx, payouts).GetHash() != importTx.GetHash())
|
||||||
return Invalid("non-canonical");
|
return Invalid("non-canonical");
|
||||||
// burn params
|
// burn params
|
||||||
if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCcid, payoutsHash))
|
if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCcid, payoutsHash,rawproof))
|
||||||
return Invalid("invalid-burn-tx");
|
return Invalid("invalid-burn-tx");
|
||||||
// check burn amount
|
// check burn amount
|
||||||
{
|
{
|
||||||
@@ -156,26 +162,34 @@ bool Eval::ImportCoin(const std::vector<uint8_t> params,const CTransaction &impo
|
|||||||
if (!CheckMoMoM(proof.first, target))
|
if (!CheckMoMoM(proof.first, target))
|
||||||
return Invalid("momom-check-fail");
|
return Invalid("momom-check-fail");
|
||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_SELFIMPORT == targetSymbol ) // various selfchain imports
|
else
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SELFIMPORT == "BEAM" )
|
if ( targetSymbol == "BEAM" )
|
||||||
{
|
{
|
||||||
if ( CheckBEAMimport(proof,burnTx,payouts) < 0 )
|
if ( ASSETCHAINS_BEAMPORT == 0 )
|
||||||
|
return Invalid("BEAM-import-without-port");
|
||||||
|
else if ( CheckBEAMimport(proof,rawproof,burnTx,payouts) < 0 )
|
||||||
return Invalid("BEAM-import-failure");
|
return Invalid("BEAM-import-failure");
|
||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_SELFIMPORT == "CODA" )
|
else if ( targetSymbol == "CODA" )
|
||||||
{
|
{
|
||||||
if ( CheckCODAimport(proof,burnTx,payouts) < 0 )
|
if ( ASSETCHAINS_CODAPORT == 0 )
|
||||||
|
return Invalid("CODA-import-without-port");
|
||||||
|
else if ( CheckCODAimport(proof,rawproof,burnTx,payouts) < 0 )
|
||||||
return Invalid("CODA-import-failure");
|
return Invalid("CODA-import-failure");
|
||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_SELFIMPORT == "PUBKEY" )
|
else if ( targetSymbol == "PUBKEY" )
|
||||||
{
|
{
|
||||||
if ( CheckPUBKEYimport(proof,burnTx,payouts) < 0 )
|
if ( ASSETCHAINS_SELFIMPORT != "PUBKEY" )
|
||||||
|
return Invalid("PUBKEY-import-when-notPUBKEY");
|
||||||
|
else if ( CheckPUBKEYimport(proof,rawproof,burnTx,payouts) < 0 )
|
||||||
return Invalid("PUBKEY-import-failure");
|
return Invalid("PUBKEY-import-failure");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( CheckGATEWAYimport(targetSymbol,proof,burnTx,payouts) < 0 )
|
if ( targetSymbol != ASSETCHAINS_SELFIMPORT )
|
||||||
|
return Invalid("invalid-gateway-import-coin");
|
||||||
|
else if ( CheckGATEWAYimport(proof,rawproof,burnTx,payouts) < 0 )
|
||||||
return Invalid("GATEWAY-import-failure");
|
return Invalid("GATEWAY-import-failure");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,16 +214,14 @@ cont:
|
|||||||
*/
|
*/
|
||||||
void CompleteImportTransaction(CTransaction &importTx)
|
void CompleteImportTransaction(CTransaction &importTx)
|
||||||
{
|
{
|
||||||
TxProof proof;
|
TxProof proof; CTransaction burnTx; std::vector<CTxOut> payouts; std::vector<uint8_t> rawproof;
|
||||||
CTransaction burnTx;
|
|
||||||
std::vector<CTxOut> payouts;
|
|
||||||
if (!UnmarshalImportTx(importTx, proof, burnTx, payouts))
|
if (!UnmarshalImportTx(importTx, proof, burnTx, payouts))
|
||||||
throw std::runtime_error("Couldn't parse importTx");
|
throw std::runtime_error("Couldn't parse importTx");
|
||||||
|
|
||||||
std::string targetSymbol;
|
std::string targetSymbol;
|
||||||
uint32_t targetCCid;
|
uint32_t targetCCid;
|
||||||
uint256 payoutsHash;
|
uint256 payoutsHash;
|
||||||
if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash))
|
if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCCid, payoutsHash, rawproof))
|
||||||
throw std::runtime_error("Couldn't parse burnTx");
|
throw std::runtime_error("Couldn't parse burnTx");
|
||||||
|
|
||||||
proof = GetCrossChainProof(burnTx.GetHash(), targetSymbol.data(), targetCCid, proof);
|
proof = GetCrossChainProof(burnTx.GetHash(), targetSymbol.data(), targetCCid, proof);
|
||||||
|
|||||||
@@ -38,11 +38,22 @@ CTransaction MakeImportCoinTransaction(const TxProof proof, const CTransaction b
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector<CTxOut> payouts)
|
CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector<CTxOut> payouts,std::vector<uint8_t> rawproof)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> opret = E_MARSHAL(ss << VARINT(targetCCid);
|
std::vector<uint8_t> opret;
|
||||||
ss << targetSymbol;
|
if ( targetCCid != 0xffffffff )
|
||||||
ss << SerializeHash(payouts));
|
{
|
||||||
|
opret = E_MARSHAL(ss << VARINT(targetCCid);
|
||||||
|
ss << targetSymbol;
|
||||||
|
ss << SerializeHash(payouts));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
opret = E_MARSHAL(ss << VARINT(targetCCid);
|
||||||
|
ss << targetSymbol;
|
||||||
|
ss << SerializeHash(payouts);
|
||||||
|
ss << rawproof);
|
||||||
|
}
|
||||||
return CTxOut(value, CScript() << OP_RETURN << opret);
|
return CTxOut(value, CScript() << OP_RETURN << opret);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,14 +71,25 @@ bool UnmarshalImportTx(const CTransaction &importTx, TxProof &proof, CTransactio
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint32_t *targetCCid, uint256 &payoutsHash)
|
bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint32_t *targetCCid, uint256 &payoutsHash,std::vector<uint8_t>&rawproof)
|
||||||
{
|
{
|
||||||
std::vector<uint8_t> burnOpret;
|
std::vector<uint8_t> burnOpret; uint32_t ccid = 0;
|
||||||
if (burnTx.vout.size() == 0) return false;
|
if (burnTx.vout.size() == 0) return false;
|
||||||
GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret);
|
GetOpReturnData(burnTx.vout.back().scriptPubKey, burnOpret);
|
||||||
return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid);
|
E_UNMARSHAL(burnOpret, ss >> VARINT(ccid));
|
||||||
ss >> targetSymbol;
|
if ( ccid != 0xffffffff )
|
||||||
ss >> payoutsHash);
|
{
|
||||||
|
return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid);
|
||||||
|
ss >> targetSymbol;
|
||||||
|
ss >> payoutsHash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return E_UNMARSHAL(burnOpret, ss >> VARINT(*targetCCid);
|
||||||
|
ss >> targetSymbol;
|
||||||
|
ss >> payoutsHash;
|
||||||
|
ss >> rawproof);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ CTransaction MakeImportCoinTransaction(const TxProof proof,
|
|||||||
|
|
||||||
CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector<CTxOut> payouts);
|
CTxOut MakeBurnOutput(CAmount value, uint32_t targetCCid, std::string targetSymbol, const std::vector<CTxOut> payouts);
|
||||||
|
|
||||||
bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint32_t *targetCCid, uint256 &payoutsHash);
|
bool UnmarshalBurnTx(const CTransaction &burnTx, std::string &targetSymbol, uint32_t *targetCCid, uint256 &payoutsHash,std::vector<uint8_t> &rawproof);
|
||||||
bool UnmarshalImportTx(const CTransaction &importTx, TxProof &proof, CTransaction &burnTx,
|
bool UnmarshalImportTx(const CTransaction &importTx, TxProof &proof, CTransaction &burnTx,
|
||||||
std::vector<CTxOut> &payouts);
|
std::vector<CTxOut> &payouts);
|
||||||
|
|
||||||
|
|||||||
@@ -1775,36 +1775,33 @@ void komodo_args(char *argv0)
|
|||||||
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
|
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
|
||||||
ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0);
|
ASSETCHAINS_BEAMPORT = GetArg("-ac_beam",0);
|
||||||
ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0);
|
ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0);
|
||||||
|
if ( ASSETCHAINS_BEAMPORT != 0 && ASSETCHAINS_CODAPORT != 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"can only have one of -ac_beam or -ac_coda\n");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
ASSETCHAINS_SELFIMPORT = GetArg("-ac_import",""); // BEAM, CODA, PUBKEY, GATEWAY
|
ASSETCHAINS_SELFIMPORT = GetArg("-ac_import",""); // BEAM, CODA, PUBKEY, GATEWAY
|
||||||
if ( ASSETCHAINS_SELFIMPORT == "PUBKEY" )
|
if ( ASSETCHAINS_SELFIMPORT == "PUBKEY" )
|
||||||
{
|
{
|
||||||
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) != 66 )
|
if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) != 66 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"invalid -ac_pubkey for -ac_import=PUBKEY\n");
|
fprintf(stderr,"invalid -ac_pubkey for -ac_import=PUBKEY\n");
|
||||||
ASSETCHAINS_SELFIMPORT = "";
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_SELFIMPORT == "BEAM" && ASSETCHAINS_BEAMPORT == 0 )
|
else if ( ASSETCHAINS_SELFIMPORT == "BEAM" && ASSETCHAINS_BEAMPORT == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"missing -ac_beam for BEAM rpcport\n");
|
fprintf(stderr,"missing -ac_beam for BEAM rpcport\n");
|
||||||
ASSETCHAINS_SELFIMPORT = "";
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_SELFIMPORT == "CODA" && ASSETCHAINS_CODAPORT == 0 )
|
else if ( ASSETCHAINS_SELFIMPORT == "CODA" && ASSETCHAINS_CODAPORT == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"missing -ac_coda for CODA rpcport\n");
|
fprintf(stderr,"missing -ac_coda for CODA rpcport\n");
|
||||||
ASSETCHAINS_SELFIMPORT = "";
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_SELFIMPORT.size() > 0 && ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID )
|
// else it can be gateway coin
|
||||||
{
|
|
||||||
fprintf(stderr,"selfimport chains cant be in a fungible cluster\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
//ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0);
|
|
||||||
|
|
||||||
|
|
||||||
if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 )
|
if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 )
|
||||||
ASSETCHAINS_STAKED = 100;
|
ASSETCHAINS_STAKED = 100;
|
||||||
|
|
||||||
@@ -1857,7 +1854,7 @@ void komodo_args(char *argv0)
|
|||||||
printf("ASSETCHAINS_FOUNDERS needs an ASETCHAINS_OVERRIDE_PUBKEY\n");
|
printf("ASSETCHAINS_FOUNDERS needs an ASETCHAINS_OVERRIDE_PUBKEY\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 )
|
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 || ASSETCHAINS_SELFIMPORT.size() > 0 || ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF|| ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH || ASSETCHAINS_LWMAPOS != 0 || ASSETCHAINS_LASTERA > 0 || ASSETCHAINS_BEAMPORT != 0 || ASSETCHAINS_CODAPORT != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size());
|
fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size());
|
||||||
extraptr = extrabuf;
|
extraptr = extrabuf;
|
||||||
@@ -1927,6 +1924,10 @@ void komodo_args(char *argv0)
|
|||||||
fprintf(stderr," selfimport\n");
|
fprintf(stderr," selfimport\n");
|
||||||
extralen += ASSETCHAINS_SELFIMPORT.size();
|
extralen += ASSETCHAINS_SELFIMPORT.size();
|
||||||
}
|
}
|
||||||
|
if ( ASSETCHAINS_BEAMPORT != 0 )
|
||||||
|
extraptr[extralen++] = 'b';
|
||||||
|
if ( ASSETCHAINS_CODAPORT != 0 )
|
||||||
|
extraptr[extralen++] = 'c';
|
||||||
}
|
}
|
||||||
|
|
||||||
addn = GetArg("-seednode","");
|
addn = GetArg("-seednode","");
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ struct komodo_ccdata_entry *komodo_allMoMs(int32_t *nump,uint256 *MoMoMp,int32_t
|
|||||||
uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth);
|
uint256 komodo_calcMoM(int32_t height,int32_t MoMdepth);
|
||||||
extern std::string ASSETCHAINS_SELFIMPORT;
|
extern std::string ASSETCHAINS_SELFIMPORT;
|
||||||
uint256 Parseuint256(char *hexstr);
|
uint256 Parseuint256(char *hexstr);
|
||||||
int32_t GetSelfimportProof(CMutableTransaction &mtx,CScript &scriptPubKey,TxProof &proof,uint64_t burnAmount,std::vector<uint8_t> rawtx,uint256 txid,std::vector<uint8_t> rawproof);
|
int32_t GetSelfimportProof(std::string source,CMutableTransaction &mtx,CScript &scriptPubKey,TxProof &proof,uint64_t burnAmount,std::vector<uint8_t> rawtx,uint256 txid,std::vector<uint8_t> rawproof);
|
||||||
|
|
||||||
|
|
||||||
UniValue assetchainproof(const UniValue& params, bool fHelp)
|
UniValue assetchainproof(const UniValue& params, bool fHelp)
|
||||||
@@ -199,8 +199,8 @@ UniValue migrate_converttoexport(const UniValue& params, bool fHelp)
|
|||||||
if (burnAmount < needed)
|
if (burnAmount < needed)
|
||||||
throw runtime_error("export_amount too small");
|
throw runtime_error("export_amount too small");
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_SELFIMPORT.size() > 0 )
|
//if ( ASSETCHAINS_SELFIMPORT.size() > 0 )
|
||||||
throw runtime_error("self-import chains cant be fungible");
|
// throw runtime_error("self-import chains cant be fungible");
|
||||||
CTxOut burnOut = MakeBurnOutput(burnAmount, ccid, targetSymbol, tx.vout);
|
CTxOut burnOut = MakeBurnOutput(burnAmount, ccid, targetSymbol, tx.vout);
|
||||||
UniValue ret(UniValue::VOBJ);
|
UniValue ret(UniValue::VOBJ);
|
||||||
ret.push_back(Pair("payouts", HexStr(E_MARSHAL(ss << tx.vout))));
|
ret.push_back(Pair("payouts", HexStr(E_MARSHAL(ss << tx.vout))));
|
||||||
@@ -278,18 +278,23 @@ UniValue migrate_completeimporttransaction(const UniValue& params, bool fHelp)
|
|||||||
UniValue selfimport(const UniValue& params, bool fHelp)
|
UniValue selfimport(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
CMutableTransaction mtx;
|
CMutableTransaction mtx;
|
||||||
TxProof proof; CTransaction burnTx,tx; CTxOut burnOut; uint64_t burnAmount; uint256 txid,blockHash; std::vector<CTxOut> vouts; std::vector<uint8_t> rawtx,rawproof; CScript scriptPubKey;
|
std::string source; TxProof proof; CTransaction burnTx,tx; CTxOut burnOut; uint64_t burnAmount; uint256 txid,blockHash; std::vector<CTxOut> vouts; std::vector<uint8_t> rawtx,rawproof; CScript scriptPubKey;
|
||||||
if ( ASSETCHAINS_SELFIMPORT.size() == 0 )
|
if ( ASSETCHAINS_SELFIMPORT.size() == 0 )
|
||||||
throw runtime_error("selfimport only works on -ac_import chains");
|
throw runtime_error("selfimport only works on -ac_import chains");
|
||||||
if (fHelp || params.size() < 3 || params.size() > 4)
|
if (fHelp || params.size() < 3 || params.size() > 5 )
|
||||||
throw runtime_error("selfimport rawtx txid burnamount\n\n"
|
throw runtime_error("selfimport rawtx txid burnamount [rawproof source]\n\n"
|
||||||
"creates signed selfimport transaction from txid");
|
"creates signed selfimport transaction from txid");
|
||||||
rawtx = ParseHex(params[0].get_str().c_str());
|
rawtx = ParseHex(params[0].get_str().c_str());
|
||||||
txid = Parseuint256((char *)params[1].get_str().c_str()); // allow for txid != hash(rawtx)
|
txid = Parseuint256((char *)params[1].get_str().c_str()); // allow for txid != hash(rawtx)
|
||||||
burnAmount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
burnAmount = atof(params[2].get_str().c_str()) * COIN + 0.00000000499999;
|
||||||
if ( params.size() == 4 )
|
source = ASSETCHAINS_SELFIMPORT;
|
||||||
|
if ( params.size() >= 4 )
|
||||||
|
{
|
||||||
rawproof = ParseHex(params[3].get_str().c_str());
|
rawproof = ParseHex(params[3].get_str().c_str());
|
||||||
if ( GetSelfimportProof(mtx,scriptPubKey,proof,burnAmount,rawtx,txid,rawproof) < 0 )
|
if ( params.size() == 5 )
|
||||||
|
source = params[4].get_str();
|
||||||
|
}
|
||||||
|
if ( GetSelfimportProof(source,mtx,scriptPubKey,proof,burnAmount,rawtx,txid,rawproof) < 0 )
|
||||||
throw std::runtime_error("Failed validating selfimport");
|
throw std::runtime_error("Failed validating selfimport");
|
||||||
vouts = mtx.vout;
|
vouts = mtx.vout;
|
||||||
burnOut = MakeBurnOutput(burnAmount,0xffffffff,ASSETCHAINS_SELFIMPORT,vouts);
|
burnOut = MakeBurnOutput(burnAmount,0xffffffff,ASSETCHAINS_SELFIMPORT,vouts);
|
||||||
|
|||||||
Reference in New Issue
Block a user