Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cppForSwig/AsyncClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,7 @@ void AsyncClient::BlockDataViewer::getCombinedBalances(std::function<void(

///////////////////////////////////////////////////////////////////////////////
void AsyncClient::BlockDataViewer::getOutputsForAddresses(
std::set<BinaryData>& addrSet, uint32_t heightCutoff, uint32_t zcCutoff,
const std::set<BinaryData>& addrSet, uint32_t heightCutoff, uint32_t zcCutoff,
std::function<void(ReturnMessage<OutputBatch>)> callback)
{
//create capnp request
Expand All @@ -1692,7 +1692,7 @@ void AsyncClient::BlockDataViewer::getOutputsForAddresses(
//populate request data
auto capnAddrs = addrReq.initAddresses(addrSet.size());
unsigned i = 0;
for (auto& addr : addrSet) {
for (const auto& addr : addrSet) {
auto capnAddr = capnAddrs[i++];
capnAddr.setBody(capnp::Data::Builder(
(uint8_t*)addr.getPtr(), addr.getSize()
Expand Down
2 changes: 1 addition & 1 deletion cppForSwig/AsyncClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ namespace AsyncClient
void getCombinedBalances(std::function<void(
ReturnMessage<std::map<std::string, CombinedBalances>>)>);

void getOutputsForAddresses(std::set<BinaryData>&, uint32_t, uint32_t,
void getOutputsForAddresses(const std::set<BinaryData>&, uint32_t, uint32_t,
std::function<void(ReturnMessage<OutputBatch>)>);
void getOutputsForOutpoints(
const std::map<BinaryData, std::set<unsigned>>&, bool,
Expand Down
14 changes: 7 additions & 7 deletions cppForSwig/Signer/CoinSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ std::vector<UTXO> RestrictedUtxoSet::getUtxoSelection() const

////////////////////////////////////////////////////////////////////////////////
// CoinSelection
std::vector<UTXO> CoinSelection::CoinSelection::checkForRecipientReuse(
std::vector<UTXO> Armory::CoinSelection::CoinSelection::checkForRecipientReuse(
PaymentStruct& payStruct, const std::vector<UTXO>& utxoVec)
{
//look for recipient reuse
Expand Down Expand Up @@ -144,7 +144,7 @@ std::vector<UTXO> CoinSelection::CoinSelection::checkForRecipientReuse(
}

////////////////////////////////////////////////////////////////////////////////
UtxoSelection CoinSelection::CoinSelection::getUtxoSelectionForRecipients(
UtxoSelection Armory::CoinSelection::CoinSelection::getUtxoSelectionForRecipients(
PaymentStruct& payStruct, const std::vector<UTXO>& utxoVec)
{
try {
Expand All @@ -167,7 +167,7 @@ UtxoSelection CoinSelection::CoinSelection::getUtxoSelectionForRecipients(
}

////////////////////////////////////////////////////////////////////////////////
UtxoSelection CoinSelection::CoinSelection::getUtxoSelection(
UtxoSelection Armory::CoinSelection::CoinSelection::getUtxoSelection(
PaymentStruct& payStruct, const std::vector<UTXO>& utxoVec)
{
if (utxoVec.empty()) {
Expand Down Expand Up @@ -298,7 +298,7 @@ UtxoSelection CoinSelection::CoinSelection::getUtxoSelection(
}

////////////////////////////////////////////////////////////////////////////////
void CoinSelection::CoinSelection::updateUtxoVector(uint64_t value)
void Armory::CoinSelection::CoinSelection::updateUtxoVector(uint64_t value)
{
if (utxoVecValue_ >= value) {
return;
Expand All @@ -312,7 +312,7 @@ void CoinSelection::CoinSelection::updateUtxoVector(uint64_t value)
}

////////////////////////////////////////////////////////////////////////////////
uint64_t CoinSelection::CoinSelection::tallyValue(
uint64_t Armory::CoinSelection::CoinSelection::tallyValue(
const std::vector<UTXO>& utxoVec)
{
uint64_t val = 0;
Expand All @@ -323,7 +323,7 @@ uint64_t CoinSelection::CoinSelection::tallyValue(
}

////////////////////////////////////////////////////////////////////////////////
uint64_t CoinSelection::CoinSelection::getFeeForMaxVal(
uint64_t Armory::CoinSelection::CoinSelection::getFeeForMaxVal(
size_t txOutSize, float fee_byte,
const std::vector<UTXO>& coinControlVec)
{
Expand Down Expand Up @@ -359,7 +359,7 @@ uint64_t CoinSelection::CoinSelection::getFeeForMaxVal(
}

////////////////////////////////////////////////////////////////////////////////
void CoinSelection::CoinSelection::fleshOutSelection(
void Armory::CoinSelection::CoinSelection::fleshOutSelection(
const std::vector<UTXO>& utxoVec,
UtxoSelection& utxoSelect, PaymentStruct& payStruct)
{
Expand Down
1 change: 1 addition & 0 deletions cppForSwig/Signer/ScriptSpender.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <functional>
#include <vector>
#include <string>
#include <map>
Expand Down
2 changes: 1 addition & 1 deletion cppForSwig/Signer/Signer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ std::shared_ptr<SigHashData> Signer::getSigHashDataForSpender(bool sw) const
return SHD;
}

std::unique_ptr<TransactionVerifier> Signer::getVerifier(
std::unique_ptr<Armory::Signing::TransactionVerifier> Signer::getVerifier(
std::shared_ptr<BCTX> bctx,
std::map<BinaryData, std::map<unsigned, UTXO>>& utxoMap)
{
Expand Down
44 changes: 22 additions & 22 deletions cppForSwig/Signer/Transactions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ unsigned TransactionStub::getLastCodeSeparatorOffset(unsigned index) const

////////////////////////////////////////////////////////////////////////////////
// TransactionVerifier
TransactionVerifier::TransactionVerifier(
Armory::Signing::TransactionVerifier::TransactionVerifier(
const BCTX& theTx, const UtxoMap& utxos) :
utxos_(utxos), theTx_(theTx)
{
Expand All @@ -70,7 +70,7 @@ TransactionVerifier::TransactionVerifier(
}
}

TransactionVerifier::TransactionVerifier(
Armory::Signing::TransactionVerifier::TransactionVerifier(
const BCTX& theTx, const std::vector<UnspentTxOut>& unspentVec) :
theTx_(theTx)
{
Expand All @@ -93,7 +93,7 @@ TransactionVerifier::TransactionVerifier(
}
}

TransactionVerifier::TransactionVerifier(
Armory::Signing::TransactionVerifier::TransactionVerifier(
const BCTX& theTx, const std::vector<UTXO>& utxoVec) :
theTx_(theTx)
{
Expand All @@ -112,23 +112,23 @@ TransactionVerifier::TransactionVerifier(
}

////////
uint32_t TransactionVerifier::getVersion() const
uint32_t Armory::Signing::TransactionVerifier::getVersion() const
{
return theTx_.version_;
}

uint32_t TransactionVerifier::getTxOutCount() const
uint32_t Armory::Signing::TransactionVerifier::getTxOutCount() const
{
return theTx_.txouts_.size();
}

uint32_t TransactionVerifier::getLockTime() const
uint32_t Armory::Signing::TransactionVerifier::getLockTime() const
{
return theTx_.lockTime_;
}

////////
bool TransactionVerifier::verify(bool noCatch, bool strict) const
bool Armory::Signing::TransactionVerifier::verify(bool noCatch, bool strict) const
{
if (strict) {
//check value in vs value out
Expand All @@ -147,7 +147,7 @@ bool TransactionVerifier::verify(bool noCatch, bool strict) const
}

////////////////////////////////////////////////////////////////////////////////
TxEvalState TransactionVerifier::evaluateState(
TxEvalState Armory::Signing::TransactionVerifier::evaluateState(
bool strict) const
{
/*
Expand All @@ -159,7 +159,7 @@ TxEvalState TransactionVerifier::evaluateState(
}

////////////////////////////////////////////////////////////////////////////////
uint64_t TransactionVerifier::checkOutputs() const
uint64_t Armory::Signing::TransactionVerifier::checkOutputs() const
{
/*check values and return fee, return UINT64_MAX on failure*/

Expand Down Expand Up @@ -203,7 +203,7 @@ uint64_t TransactionVerifier::checkOutputs() const
}

////////////////////////////////////////////////////////////////////////////////
void TransactionVerifier::checkSigs() const
void Armory::Signing::TransactionVerifier::checkSigs() const
{
txEvalState_.reset();
for (unsigned i = 0; i < theTx_.txins_.size(); i++) {
Expand All @@ -217,7 +217,7 @@ void TransactionVerifier::checkSigs() const
}

////////////////////////////////////////////////////////////////////////////////
void TransactionVerifier::checkSigs_NoCatch() const
void Armory::Signing::TransactionVerifier::checkSigs_NoCatch() const
{
txEvalState_.reset();
for (unsigned i = 0; i < theTx_.txins_.size(); i++) {
Expand All @@ -228,7 +228,7 @@ void TransactionVerifier::checkSigs_NoCatch() const

////////////////////////////////////////////////////////////////////////////////
std::unique_ptr<StackInterpreter>
TransactionVerifier::getStackInterpreter(unsigned inputid) const
Armory::Signing::TransactionVerifier::getStackInterpreter(unsigned inputid) const
{
auto sstack = std::make_unique<StackInterpreter>(this, inputid);
auto flags = sstack->getFlags();
Expand All @@ -238,7 +238,7 @@ TransactionVerifier::getStackInterpreter(unsigned inputid) const
}

////////////////////////////////////////////////////////////////////////////////
TxInEvalState TransactionVerifier::checkSig(unsigned inputId,
TxInEvalState Armory::Signing::TransactionVerifier::checkSig(unsigned inputId,
StackInterpreter* sstack_ptr) const
{
//grab the uxto
Expand Down Expand Up @@ -297,7 +297,7 @@ TxInEvalState TransactionVerifier::checkSig(unsigned inputId,
}

////////////////////////////////////////////////////////////////////////////////
BinaryDataRef TransactionVerifier::getSerializedOutputScripts() const
BinaryDataRef Armory::Signing::TransactionVerifier::getSerializedOutputScripts() const
{
auto txOutCount = theTx_.txouts_.size();
auto firstTxOutOffset = theTx_.txouts_[0].first;
Expand All @@ -309,7 +309,7 @@ BinaryDataRef TransactionVerifier::getSerializedOutputScripts() const
}

////////////////////////////////////////////////////////////////////////////////
std::vector<TxInData> TransactionVerifier::getTxInsData() const
std::vector<TxInData> Armory::Signing::TransactionVerifier::getTxInsData() const
{
auto txInCount = theTx_.txins_.size();
std::vector<TxInData> datavec;
Expand All @@ -332,7 +332,7 @@ std::vector<TxInData> TransactionVerifier::getTxInsData() const
}

////////////////////////////////////////////////////////////////////////////////
BinaryData TransactionVerifier::getSubScript(unsigned index) const
BinaryData Armory::Signing::TransactionVerifier::getSubScript(unsigned index) const
{
auto txinref = theTx_.getTxInRef(index);
auto outputHash = txinref.getSliceRef(0, 32);
Expand All @@ -359,7 +359,7 @@ BinaryData TransactionVerifier::getSubScript(unsigned index) const
}

////////////////////////////////////////////////////////////////////////////////
BinaryDataRef TransactionVerifier::getWitnessData(unsigned inputId) const
BinaryDataRef Armory::Signing::TransactionVerifier::getWitnessData(unsigned inputId) const
{
if (inputId >= theTx_.witnesses_.size()) {
throw std::runtime_error("invalid witness data id");
Expand All @@ -371,7 +371,7 @@ BinaryDataRef TransactionVerifier::getWitnessData(unsigned inputId) const
}

////////////////////////////////////////////////////////////////////////////////
BinaryData TransactionVerifier::serializeAllOutpoints() const
BinaryData Armory::Signing::TransactionVerifier::serializeAllOutpoints() const
{
BinaryWriter bw;
for (unsigned i = 0; i < theTx_.txins_.size(); i++) {
Expand All @@ -381,7 +381,7 @@ BinaryData TransactionVerifier::serializeAllOutpoints() const
}

////////////////////////////////////////////////////////////////////////////////
BinaryData TransactionVerifier::serializeAllSequences() const
BinaryData Armory::Signing::TransactionVerifier::serializeAllSequences() const
{
BinaryWriter bw;
for (const auto& txinOnS : theTx_.txins_) {
Expand All @@ -394,7 +394,7 @@ BinaryData TransactionVerifier::serializeAllSequences() const
}

////////////////////////////////////////////////////////////////////////////////
BinaryDataRef TransactionVerifier::getOutpoint(unsigned inputID) const
BinaryDataRef Armory::Signing::TransactionVerifier::getOutpoint(unsigned inputID) const
{
if (inputID >= theTx_.txins_.size()) {
throw std::runtime_error("invalid txin index");
Expand All @@ -404,7 +404,7 @@ BinaryDataRef TransactionVerifier::getOutpoint(unsigned inputID) const
}

////////////////////////////////////////////////////////////////////////////////
uint64_t TransactionVerifier::getOutpointValue(unsigned inputID) const
uint64_t Armory::Signing::TransactionVerifier::getOutpointValue(unsigned inputID) const
{
auto outpoint = getOutpoint(inputID);
auto outputHash = outpoint.getSliceRef(0, 32);
Expand All @@ -424,7 +424,7 @@ uint64_t TransactionVerifier::getOutpointValue(unsigned inputID) const
}

////////////////////////////////////////////////////////////////////////////////
unsigned TransactionVerifier::getTxInSequence(unsigned inputID) const
unsigned Armory::Signing::TransactionVerifier::getTxInSequence(unsigned inputID) const
{
if (inputID >= theTx_.txins_.size()) {
throw ScriptException("invalid txin index");
Expand Down
2 changes: 1 addition & 1 deletion cppForSwig/SocketObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using namespace std::chrono_literals;

#ifdef _WIN32
//i dont know how to get linkage for this with MSYS2 halp T_T
char *gai_strerrorA(int errcode) { return nullptr; }
//already has a body: char *gai_strerrorA(int errcode) { return nullptr; }
#endif

///////////////////////////////////////////////////////////////////////////////
Expand Down
1 change: 1 addition & 0 deletions cppForSwig/SocketService_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
////////////////////////////////////////////////////////////////////////////////

#include "SocketService.h"
#include "Utils/log.h"

using namespace std;
using namespace Armory::Threading;
Expand Down
10 changes: 5 additions & 5 deletions cppForSwig/Utils/ArmoryConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ std::pair<std::string_view, std::string_view> SettingsUtils::getKeyValFromLine(
auto iter = line.begin();
while (iter != line.end()) {
if (*iter == delim) {
output.first = std::string_view(line.begin(), iter - line.begin());
output.first = line.substr(0, iter-line.cbegin());
break;
}
++iter;
Expand All @@ -277,7 +277,7 @@ std::pair<std::string_view, std::string_view> SettingsUtils::getKeyValFromLine(
/* we're not at the end of the line, there's a value to parse */
//skip the the delimiter
++iter;
output.second = std::string_view(iter, line.end()-iter);
output.second = line.substr(iter - line.cbegin());
} else {
/* we're at the end of the line, there's only a key */
output.first = line;
Expand Down Expand Up @@ -329,7 +329,7 @@ std::string_view SettingsUtils::stripQuotes(const std::string_view& input)
--len;
}

return std::string_view(input.begin() + start, len);
return input.substr(start, len);
}

////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -693,10 +693,10 @@ void NetworkSettings::processArgs(
iter = args.find("satoshirpc-port");
if (iter != args.end()) {
auto value = SettingsUtils::stripQuotes(iter->second);
int portInt;
int portInt = 0;

try {
std::from_chars(value.begin(), value.end(), portInt);
portInt = std::stoi(std::string(value));
if (portInt < 1 || portInt > 65535) {
std::cout << "Invalid satoshi rpc port, falling back to default" << std::endl;
} else {
Expand Down
4 changes: 4 additions & 0 deletions cppForSwig/Utils/BinaryData.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ inline constexpr uint8_t binLookupTable[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};

#ifdef WIN32
typedef long long ssize_t;
#endif

////////////////////////////////////////////////////////////////////////////////
class BinaryData
{
Expand Down
2 changes: 1 addition & 1 deletion cppForSwig/Utils/BtcUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const BinaryData BtcUtils::BadAddress = BinaryData::CreateFromHex(
const BinaryData BtcUtils::EmptyHash = BinaryData::CreateFromHex(
"0000000000000000000000000000000000000000000000000000000000000000");

constexpr char BtcUtils::base64Chars[]{
static const char BtcUtils::base64Chars[]{
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"};

const std::map<char, uint8_t> BtcUtils::base64Vals = {
Expand Down
6 changes: 3 additions & 3 deletions cppForSwig/Utils/Cryptography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ std::once_flag contexFlag;
using namespace Cryptography;
using namespace std::string_view_literals;

constexpr std::string_view ECDSA::bitcoinMessageMagic{
"Bitcoin Signed Message:\n"sv
static const std::string_view ECDSA::bitcoinMessageMagic{
"Bitcoin Signed Message:\n"
};
constexpr size_t Encryption::AES::BLOCK_SIZE = AES_BLOCK_SIZE;
static const size_t Encryption::AES::BLOCK_SIZE = AES_BLOCK_SIZE;
secp256k1_context* ECDSA::crypto_ecdsa_ctx = nullptr;
const PRNG::Fortuna PRNG::fortuna;

Expand Down
Loading