Hush Full Node software. We were censored from Github, this is where all development happens now.
https://hush.is
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
3.4 KiB
129 lines
3.4 KiB
// Copyright (c) 2016-2023 The Hush developers
|
|
/******************************************************************************
|
|
* Copyright © 2014-2019 The SuperNET Developers. *
|
|
* *
|
|
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
|
|
* the top-level directory of this distribution for the individual copyright *
|
|
* holder information and the developer policies on copyright and licensing. *
|
|
* *
|
|
* Unless otherwise agreed in a custom licensing agreement, no part of the *
|
|
* SuperNET software, including this file may be copied, modified, propagated *
|
|
* or distributed except according to the terms contained in the LICENSE file *
|
|
* *
|
|
* Removal or modification of this copyright notice is prohibited. *
|
|
* *
|
|
******************************************************************************/
|
|
|
|
#include "cryptoconditions/include/cryptoconditions.h"
|
|
#include "script/cc.h"
|
|
|
|
|
|
bool IsCryptoConditionsEnabled()
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
|
|
bool IsSupportedCryptoCondition(const CC *cond)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
bool IsSignedCryptoCondition(const CC *cond)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
static unsigned char* CopyPubKey(CPubKey pkIn)
|
|
{
|
|
unsigned char* pk = (unsigned char*) malloc(33);
|
|
memcpy(pk, pkIn.begin(), 33); // TODO: compressed?
|
|
return pk;
|
|
}
|
|
|
|
|
|
CC* CCNewThreshold(int t, std::vector<CC*> v)
|
|
{
|
|
CC *cond = cc_new(CC_Threshold);
|
|
cond->threshold = t;
|
|
cond->size = v.size();
|
|
cond->subconditions = (CC**) calloc(v.size(), sizeof(CC*));
|
|
memcpy(cond->subconditions, v.data(), v.size() * sizeof(CC*));
|
|
return cond;
|
|
}
|
|
|
|
|
|
CC* CCNewSecp256k1(CPubKey k)
|
|
{
|
|
CC *cond = cc_new(CC_Secp256k1);
|
|
cond->publicKey = CopyPubKey(k);
|
|
return cond;
|
|
}
|
|
|
|
|
|
CC* CCNewEval(std::vector<unsigned char> code)
|
|
{
|
|
CC *cond = cc_new(CC_Eval);
|
|
cond->code = (unsigned char*) malloc(code.size());
|
|
memcpy(cond->code, code.data(), code.size());
|
|
cond->codeLength = code.size();
|
|
return cond;
|
|
}
|
|
|
|
|
|
CScript CCPubKey(const CC *cond)
|
|
{
|
|
return CScript();
|
|
}
|
|
|
|
|
|
CScript CCSig(const CC *cond)
|
|
{
|
|
return CScript();
|
|
}
|
|
|
|
std::vector<unsigned char> CCSigVec(const CC *cond)
|
|
{
|
|
unsigned char buf[10000];
|
|
size_t len = cc_fulfillmentBinary(cond, buf, 10000);
|
|
auto ffill = std::vector<unsigned char>(buf, buf+len);
|
|
ffill.push_back(1); // SIGHASH_ALL
|
|
return ffill;
|
|
}
|
|
|
|
std::string CCShowStructure(CC *cond)
|
|
{
|
|
std::string out;
|
|
return out;
|
|
}
|
|
|
|
|
|
CC* CCPrune(CC *cond)
|
|
{
|
|
std::vector<unsigned char> ffillBin;
|
|
GetPushData(CCSig(cond), ffillBin);
|
|
return cc_readFulfillmentBinary(ffillBin.data(), ffillBin.size()-1);
|
|
}
|
|
|
|
|
|
bool GetPushData(const CScript &sig, std::vector<unsigned char> &data)
|
|
{
|
|
opcodetype opcode;
|
|
auto pc = sig.begin();
|
|
if (sig.GetOp(pc, opcode, data)) return opcode > OP_0 && opcode <= OP_PUSHDATA4;
|
|
return false;
|
|
}
|
|
|
|
|
|
bool GetOpReturnData(const CScript &sig, std::vector<unsigned char> &data)
|
|
{
|
|
auto pc = sig.begin();
|
|
opcodetype opcode;
|
|
if (sig.GetOp2(pc, opcode, NULL))
|
|
if (opcode == OP_RETURN)
|
|
if (sig.GetOp(pc, opcode, data))
|
|
return opcode > OP_0 && opcode <= OP_PUSHDATA4;
|
|
return false;
|
|
}
|
|
|