Bitcoin Core version released

Bitcoin source programming problem. What is " std::vector(1.0) " ?

Where is "PUBKEY_ADDRESS", "PUBKEY_ADDRESS_TEST" variables moved to? Originally they were at src/base58.h
But at recent bitcoin source code, I found similar at chainparams.cpp
Now it says,
base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,0);
At this, what is " std::vector(1.0) " ?
Originally this was just number based on
Why simple code changed to more difficult?
submitted by wsxdrfv to Bitcoin [link] [comments]

Bitcoin source programming problem. What is " std::vector(1.0) " ? /r/Bitcoin

Bitcoin source programming problem. What is (1.0) " ? /Bitcoin" title="Bitcoin source programming problem. What is " std::vector(1.0) " ? /Bitcoin" /> submitted by HiIAMCaptainObvious to BitcoinAll [link] [comments]

Creating a public key from a private key using secp256k1 library in C++

I'm trying to generate a public key from a private one using the bitcoin library secp256k1 in C++:

 // private key std::string privateKey = "baca891f5f0285e043496843d82341d15533f016c223d114e1e4dfd39e60ecb0"; const char* cPrivateKey = privateKey.c_str(); // creating public key from it secp256k1_context *signingContext = secp256k1_context_create(SECP256K1_CONTEXT_SIGN); secp256k1_pubkey pkey; unsigned char *seckey = (unsigned char*) malloc(privateKey.size() * sizeof(unsigned char)); std::copy(cPrivateKey, cPrivateKey + privateKey.size(), seckey); if (secp256k1_ec_pubkey_create(signingContext, &pkey, seckey) == 0) throw "Creation error"; // print the result in hex std::stringstream ss; for (int i = 0; i < 64; ++i) { ss << std::setw(2) << std::hex << (0xff & (unsigned int)[i]); } std::cout << ss.str() << std::endl; // parsing the result std::string pkey_data = ss.str(); secp256k1_context *noneContext = secp256k1_context_create(SECP256K1_CONTEXT_NONE); secp256k1_pubkey pubkey; if (secp256k1_ec_pubkey_parse(noneContext, &pubkey,, 64) == 0) std::cout << "Couldnt parse using" << std::endl; if (secp256k1_ec_pubkey_parse(noneContext, &pubkey, pkay_data, pkey_data.size()) == 0) std::cout << "Couldnt parse using hex public key " << std::endl; 
The output:
1b9e55408c5141414e8337adef57ead18f62444fdf5f8c897d0dc812696a6141a919254d3e750075a2a9ba32dc4ed30c84e65f27e431b59b94a2aafe3e80a974 Couldnt parse using Couldnt parse using hex public key 
The idea is to parse the public key from the generated one to see if it is really correct. Also, i tried using openssl with the same private key and i get a different public key from the private one using ecdsa secp256k1.. Any help or example on how to use the library in C++ is more than welcome.
Thank you
submitted by chizisch to Bitcoin [link] [comments]

12-13 15:04 - 'Read this went the opposite way' (self.Bitcoin) by /u/fukya40 removed from /r/Bitcoin within 38-48min

// Copyright (c) 2008 Satoshi Nakamoto // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE.
class COutPoint; class CInPoint; class CDiskTxPos; class CCoinBase; class CTxIn; class CTxOut; class CTransaction; class CBlock; class CBlockIndex; class CWalletTx; class CKeyItem;
static const unsigned int MAX_SIZE = 0x02000000; static const int64 COIN = 1000000; static const int64 CENT = 10000; static const int64 TRANSACTIONFEE = 1 * CENT; /// change this to a user options setting, optional fee can be zero ///static const unsigned int MINPROOFOFWORK = 40; /// need to decide the right difficulty to start with static const unsigned int MINPROOFOFWORK = 20; /// ridiculously easy for testing
extern map mapBlockIndex; extern const uint256 hashGenesisBlock; extern CBlockIndex* pindexGenesisBlock; extern int nBestHeight; extern CBlockIndex* pindexBest; extern unsigned int nTransactionsUpdated; extern int fGenerateBitcoins;
FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb"); FILE* AppendBlockFile(unsigned int& nFileRet); bool AddKey(const CKey& key); vector GenerateNewKey(); bool AddToWallet(const CWalletTx& wtxIn); void ReacceptWalletTransactions(); void RelayWalletTransactions(); bool LoadBlockIndex(bool fAllowNew=true); bool BitcoinMiner(); bool ProcessMessages(CNode* pfrom); bool ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv); bool SendMessages(CNode* pto); int64 CountMoney(); bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& txNew); bool SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew);
class CDiskTxPos { public: unsigned int nFile; unsigned int nBlockPos; unsigned int nTxPos;
CDiskTxPos() { SetNull(); }
CDiskTxPos(unsigned int nFileIn, unsigned int nBlockPosIn, unsigned int nTxPosIn) { nFile = nFileIn; nBlockPos = nBlockPosIn; nTxPos = nTxPosIn; }
IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) void SetNull() { nFile = -1; nBlockPos = 0; nTxPos = 0; } bool IsNull() const { return (nFile == -1); }
friend bool operator==(const CDiskTxPos& a, const CDiskTxPos& b) { return (a.nFile == b.nFile && a.nBlockPos == b.nBlockPos && a.nTxPos == b.nTxPos); }
friend bool operator!=(const CDiskTxPos& a, const CDiskTxPos& b) { return !(a == b); }
void print() const { if (IsNull()) printf("null"); else printf("(nFile=%d, nBlockPos=%d, nTxPos=%d)", nFile, nBlockPos, nTxPos); } };
class CInPoint { public: CTransaction* ptx; unsigned int n;
CInPoint() { SetNull(); } CInPoint(CTransaction* ptxIn, unsigned int nIn) { ptx = ptxIn; n = nIn; } void SetNull() { ptx = NULL; n = -1; } bool IsNull() const { return (ptx == NULL && n == -1); } };
class COutPoint { public: uint256 hash; unsigned int n;
COutPoint() { SetNull(); } COutPoint(uint256 hashIn, unsigned int nIn) { hash = hashIn; n = nIn; } IMPLEMENT_SERIALIZE( READWRITE(FLATDATA(*this)); ) void SetNull() { hash = 0; n = -1; } bool IsNull() const { return (hash == 0 && n == -1); }
friend bool operator<(const COutPoint& a, const COutPoint& b) { return (a.hash < b.hash || (a.hash == b.hash && a.n < b.n)); }
friend bool operator==(const COutPoint& a, const COutPoint& b) { return (a.hash == b.hash && a.n == b.n); }
friend bool operator!=(const COutPoint& a, const COutPoint& b) { return !(a == b); }
void print() const { printf("COutPoint(%s, %d)", hash.ToString().substr(0,6).c_str(), n); } };
// // An input of a transaction. It contains the location of the previous // transaction's output that it claims and a signature that matches the // output's public key. // class CTxIn { public: COutPoint prevout; CScript scriptSig;
CTxIn() { }
CTxIn(COutPoint prevoutIn, CScript scriptSigIn) { prevout = prevoutIn; scriptSig = scriptSigIn; }
CTxIn(uint256 hashPrevTx, unsigned int nOut, CScript scriptSigIn) { prevout = COutPoint(hashPrevTx, nOut); scriptSig = scriptSigIn; }
bool IsPrevInMainChain() const { return CTxDB("r").ContainsTx(prevout.hash); }
friend bool operator==(const CTxIn& a, const CTxIn& b) { return (a.prevout == b.prevout && a.scriptSig == b.scriptSig); }
friend bool operator!=(const CTxIn& a, const CTxIn& b) { return !(a == b); }
void print() const { printf("CTxIn("); prevout.print(); if (prevout.IsNull()) { printf(", coinbase %s)\n", HexStr(scriptSig.begin(), scriptSig.end(), false).c_str()); } else { if (scriptSig.size() >= 6) printf(", scriptSig=%02x%02x", scriptSig[4], scriptSig[5]); printf(")\n"); } }
bool IsMine() const; int64 GetDebit() const; };
// // An output of a transaction. It contains the public key that the next input // must be able to sign with to claim it. // class CTxOut { public: int64 nValue; unsigned int nSequence; CScript scriptPubKey;
// disk only CDiskTxPos posNext; //// so far this is only used as a flag, nothing uses the location
public: CTxOut() { nValue = 0; nSequence = UINT_MAX; }
CTxOut(int64 nValueIn, CScript scriptPubKeyIn, int nSequenceIn=UINT_MAX) { nValue = nValueIn; scriptPubKey = scriptPubKeyIn; nSequence = nSequenceIn; }
uint256 GetHash() const { return SerializeHash(*this); }
bool IsFinal() const { return (nSequence == UINT_MAX); }
bool IsMine() const { return ::IsMine(scriptPubKey); }
int64 GetCredit() const { if (IsMine()) return nValue; return 0; }
friend bool operator==(const CTxOut& a, const CTxOut& b) { return (a.nValue == b.nValue && a.nSequence == b.nSequence && a.scriptPubKey == b.scriptPubKey); }
friend bool operator!=(const CTxOut& a, const CTxOut& b) { return !(a == b); }
void print() const { if (scriptPubKey.size() >= 6) printf("CTxOut(nValue=%I64d, nSequence=%u, scriptPubKey=%02x%02x, posNext=", nValue, nSequence, scriptPubKey[4], scriptPubKey[5]); posNext.print(); printf(")\n"); } };
// // The basic transaction that is broadcasted on the network and contained in // blocks. A transaction can contain multiple inputs and outputs. // class CTransaction { public: vector vin; vector vout; unsigned int nLockTime;
CTransaction() { SetNull(); }
// Set version on stream for writing back same version if (fRead && s.nVersion == -1) s.nVersion = nVersion;
void SetNull() { vin.clear(); vout.clear(); nLockTime = 0; }
bool IsNull() const { return (vin.empty() && vout.empty()); }
uint256 GetHash() const { return SerializeHash(*this); }
bool AllPrevInMainChain() const { foreach(const CTxIn& txin, vin) if (!txin.IsPrevInMainChain()) return false; return true; }
bool IsFinal() const { if (nLockTime == 0) return true; if (nLockTime < GetAdjustedTime()) return true; foreach(const CTxOut& txout, vout) if (!txout.IsFinal()) return false; return true; }
bool IsUpdate(const CTransaction& b) const { if (vin.size() != || vout.size() != b.vout.size()) return false; for (int i = 0; i < vin.size(); i++) if (vin[i].prevout !=[i].prevout) return false;
bool fNewer = false; unsigned int nLowest = UINT_MAX; for (int i = 0; i < vout.size(); i++) { if (vout[i].nSequence != b.vout[i].nSequence) { if (vout[i].nSequence <= nLowest) { fNewer = false; nLowest = vout[i].nSequence; } if (b.vout[i].nSequence < nLowest) { fNewer = true; nLowest = b.vout[i].nSequence; } } } return fNewer; }
bool IsCoinBase() const { return (vin.size() == 1 && vin[0].prevout.IsNull()); }
bool CheckTransaction() const { // Basic checks that don't depend on any context if (vin.empty() || vout.empty()) return false;
// Check for negative values int64 nValueOut = 0; foreach(const CTxOut& txout, vout) { if (txout.nValue < 0) return false; nValueOut += txout.nValue; }
if (IsCoinBase()) { if (vin[0].scriptSig.size() > 100) return false; } else { foreach(const CTxIn& txin, vin) if (txin.prevout.IsNull()) return false; }
return true; }
bool IsMine() const { foreach(const CTxOut& txout, vout) if (txout.IsMine()) return true; return false; }
int64 GetDebit() const { int64 nDebit = 0; foreach(const CTxIn& txin, vin) nDebit += txin.GetDebit(); return nDebit; }
int64 GetCredit() const { int64 nCredit = 0; foreach(const CTxOut& txout, vout) nCredit += txout.GetCredit(); return nCredit; }
int64 GetValueOut() const { int64 nValueOut = 0; foreach(const CTxOut& txout, vout) { if (txout.nValue < 0) throw runtime_error("CTransaction::GetValueOut() : negative value"); nValueOut += txout.nValue; } return nValueOut; }
bool ReadFromDisk(CDiskTxPos pos, FILE** pfileRet=NULL) { CAutoFile filein = OpenBlockFile(pos.nFile, 0, pfileRet ? "rb+" : "rb"); if (!filein) return false;
// Read transaction if (fseek(filein, pos.nTxPos, SEEK_SET) != 0) return false; filein >> *this;
// Return file pointer if (pfileRet) { if (fseek(filein, pos.nTxPos, SEEK_SET) != 0) return false; *pfileRet = filein.release(); } return true; }
friend bool operator==(const CTransaction& a, const CTransaction& b) { return ( == && a.vout == b.vout && a.nLockTime == b.nLockTime); }
friend bool operator!=(const CTransaction& a, const CTransaction& b) { return !(a == b); }
void print() const { printf("CTransaction(vin.size=%d, vout.size=%d, nLockTime=%d)\n", vin.size(), vout.size(), nLockTime); for (int i = 0; i < vin.size(); i++) { printf(" "); vin[i].print(); } for (int i = 0; i < vout.size(); i++) { printf(" "); vout[i].print(); } }
bool TestDisconnectInputs(CTxDB& txdb, map& mapTestPool) { return DisconnectInputs(txdb, mapTestPool, true); }
bool TestConnectInputs(CTxDB& txdb, map& mapTestPool, bool fMemoryTx, bool fIgnoreDiskConflicts, int64& nFees) { return ConnectInputs(txdb, mapTestPool, CDiskTxPos(1, 1, 1), 0, true, fMemoryTx, fIgnoreDiskConflicts, nFees); }
bool DisconnectInputs(CTxDB& txdb) { static map mapTestPool; return DisconnectInputs(txdb, mapTestPool, false); }
bool ConnectInputs(CTxDB& txdb, CDiskTxPos posThisTx, int nHeight) { static map mapTestPool; int64 nFees; return ConnectInputs(txdb, mapTestPool, posThisTx, nHeight, false, false, false, nFees); }
private: bool DisconnectInputs(CTxDB& txdb, map& mapTestPool, bool fTest); bool ConnectInputs(CTxDB& txdb, map& mapTestPool, CDiskTxPos posThisTx, int nHeight, bool fTest, bool fMemoryTx, bool fIgnoreDiskConflicts, int64& nFees);
public: bool AcceptTransaction(CTxDB& txdb, bool fCheckInputs=true); bool AcceptTransaction() { CTxDB txdb("r"); return AcceptTransaction(txdb); } bool ClientConnectInputs(); };
// // A transaction with a merkle branch linking it to the timechain // class CMerkleTx : public CTransaction { public: uint256 hashBlock; vector vMerkleBranch; int nIndex;
CMerkleTx() { Init(); }
CMerkleTx(const CTransaction& txIn) : CTransaction(txIn) { Init(); }
void Init() { hashBlock = 0; nIndex = -1; }
IMPLEMENT_SERIALIZE ( nSerSize += SerReadWrite(s, (CTransaction)this, nType, nVersion, ser_action); if (!(nType & SER_GETHASH)) READWRITE(nVersion); READWRITE(hashBlock); READWRITE(vMerkleBranch); READWRITE(nIndex); )
int SetMerkleBranch(); int IsInMainChain() const; bool AcceptTransaction(CTxDB& txdb, bool fCheckInputs=true); bool AcceptTransaction() { CTxDB txdb("r"); return AcceptTransaction(txdb); } };
// // A transaction with a bunch of additional info that only the owner cares // about. It includes any unrecorded transactions needed to link it back // to the timechain. // class CWalletTx : public CMerkleTx { public: vector vtxPrev; map mapValue; vector > vOrderForm; unsigned int nTime; char fFromMe; char fSpent;
//// probably need to sign the order info so know it came from payer
CWalletTx() { Init(); }
CWalletTx(const CMerkleTx& txIn) : CMerkleTx(txIn) { Init(); }
CWalletTx(const CTransaction& txIn) : CMerkleTx(txIn) { Init(); }
void Init() { nTime = 0; fFromMe = false; fSpent = false; }
IMPLEMENT_SERIALIZE ( /// would be nice for it to return the version number it reads, maybe use a reference nSerSize += SerReadWrite(s, (CMerkleTx)this, nType, nVersion, ser_action); if (!(nType & SER_GETHASH)) READWRITE(nVersion); READWRITE(vtxPrev); READWRITE(mapValue); READWRITE(vOrderForm); READWRITE(nTime); READWRITE(fFromMe); READWRITE(fSpent); )
bool WriteToDisk() { return CWalletDB().WriteTx(GetHash(), *this); }
void AddSupportingTransactions(CTxDB& txdb); void AddSupportingTransactions() { CTxDB txdb("r"); AddSupportingTransactions(txdb); }
bool AcceptWalletTransaction(CTxDB& txdb, bool fCheckInputs=true); bool AcceptWalletTransaction() { CTxDB txdb("r"); return AcceptWalletTransaction(txdb); }
void RelayWalletTransaction(CTxDB& txdb); void RelayWalletTransaction() { CTxDB txdb("r"); RelayWalletTransaction(txdb); } };
// // Nodes collect new transactions into a block, hash them into a hash tree, // and scan through nonce values to make the block's hash satisfy proof-of-work // requirements. When they solve the proof-of-work, they broadcast the block // to everyone and the block is added to the timechain. The first transaction // in the block is a special one that creates a new coin owned by the creator // of the block. // // Blocks are appended to blk0001.dat files on disk. Their location on disk // is indexed by CBlockIndex objects in memory. // class CBlock { public: // header uint256 hashPrevBlock; uint256 hashMerkleRoot; unsigned int nTime; unsigned int nBits; unsigned int nNonce;
// network and disk vector vtx;
// memory only mutable vector vMerkleTree;
CBlock() { SetNull(); }
// ConnectBlock depends on vtx being last so it can calculate offset if (!(nType & (SER_GETHASH|SER_BLOCKHEADERONLY))) READWRITE(vtx); else if (fRead) const_cast(this)->vtx.clear(); )
void SetNull() { hashPrevBlock = 0; hashMerkleRoot = 0; nTime = 0; nBits = 0; nNonce = 0; vtx.clear(); vMerkleTree.clear(); }
bool IsNull() const { return (nBits == 0); }
uint256 GetHash() const { return Hash(BEGIN(hashPrevBlock), END(nNonce)); }
uint256 BuildMerkleTree() const { vMerkleTree.clear(); foreach(const CTransaction& tx, vtx) vMerkleTree.push_back(tx.GetHash()); int j = 0; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { for (int i = 0; i < nSize; i += 2) { int i2 = min(i+1, nSize-1); vMerkleTree.push_back(Hash(BEGIN(vMerkleTree[j+i]), END(vMerkleTree[j+i]), BEGIN(vMerkleTree[j+i2]), END(vMerkleTree[j+i2]))); } j += nSize; } return (vMerkleTree.empty() ? 0 : vMerkleTree.back()); }
vector GetMerkleBranch(int nIndex) const { if (vMerkleTree.empty()) BuildMerkleTree(); vector vMerkleBranch; int j = 0; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) { int i = min(nIndex1, nSize-1); vMerkleBranch.push_back(vMerkleTree[j+i]); nIndex >>= 1; j += nSize; } return vMerkleBranch; }
static uint256 CheckMerkleBranch(uint256 hash, const vector& vMerkleBranch, int nIndex) { foreach(const uint256& otherside, vMerkleBranch) { if (nIndex & 1) hash = Hash(BEGIN(otherside), END(otherside), BEGIN(hash), END(hash)); else hash = Hash(BEGIN(hash), END(hash), BEGIN(otherside), END(otherside)); nIndex >>= 1; } return hash; }
bool WriteToDisk(bool fWriteTransactions, unsigned int& nFileRet, unsigned int& nBlockPosRet) { // Open history file to append CAutoFile fileout = AppendBlockFile(nFileRet); if (!fileout) return false; if (!fWriteTransactions) fileout.nType |= SER_BLOCKHEADERONLY;
// Write index header unsigned int nSize = fileout.GetSerializeSize(*this); fileout << FLATDATA(pchMessageStart) << nSize;
// Write block nBlockPosRet = ftell(fileout); if (nBlockPosRet == -1) return false; fileout << *this;
return true; }
bool ReadFromDisk(unsigned int nFile, unsigned int nBlockPos, bool fReadTransactions) { SetNull();
// Open history file to read CAutoFile filein = OpenBlockFile(nFile, nBlockPos, "rb"); if (!filein) return false; if (!fReadTransactions) filein.nType |= SER_BLOCKHEADERONLY;
// Read block filein >> *this;
// Check the header if (nBits < MINPROOFOFWORK || GetHash() > (~uint256(0) >> nBits)) return error("CBlock::ReadFromDisk : errors in block header");
return true; }
void print() const { printf("CBlock(hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%u, nNonce=%u, vtx=%d)\n", hashPrevBlock.ToString().substr(0,6).c_str(), hashMerkleRoot.ToString().substr(0,6).c_str(), nTime, nBits, nNonce, vtx.size()); for (int i = 0; i < vtx.size(); i++) { printf(" "); vtx[i].print(); } printf(" vMerkleTree: "); for (int i = 0; i < vMerkleTree.size(); i++) printf("%s ", vMerkleTree[i].ToString().substr(0,6).c_str()); printf("\n"); }
bool ReadFromDisk(const CBlockIndex* blockindex, bool fReadTransactions); bool TestDisconnectBlock(CTxDB& txdb, map& mapTestPool); bool TestConnectBlock(CTxDB& txdb, map& mapTestPool); bool DisconnectBlock(); bool ConnectBlock(unsigned int nFile, unsigned int nBlockPos, int nHeight); bool AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos, bool fWriteDisk); bool CheckBlock() const; bool AcceptBlock(); };
// // The timechain is a tree shaped structure starting with the // genesis block at the root, with each block potentially having multiple // candidates to be the next block. pprev and pnext link a path through the // main/longest chain. A blockindex may have multiple pprev pointing back // to it, but pnext will only point forward to the longest branch, or will // be null if the block is not part of the longest chain. // class CBlockIndex { public: CBlockIndex* pprev; CBlockIndex* pnext; unsigned int nFile; unsigned int nBlockPos; int nHeight;
CBlockIndex() { pprev = NULL; pnext = NULL; nFile = 0; nBlockPos = 0; nHeight = 0; }
CBlockIndex(unsigned int nFileIn, unsigned int nBlockPosIn) { pprev = NULL; pnext = NULL; nFile = nFileIn; nBlockPos = nBlockPosIn; nHeight = 0; }
bool IsInMainChain() const { return (pnext || this == pindexBest); }
bool EraseBlockFromDisk() { // Open history file CAutoFile fileout = OpenBlockFile(nFile, nBlockPos, "rb+"); if (!fileout) return false;
// Overwrite with empty null block CBlock block; block.SetNull(); fileout << block;
return true; }
bool TestDisconnectBlock(CTxDB& txdb, map& mapTestPool) { CBlock block; if (!block.ReadFromDisk(nFile, nBlockPos, true)) return false; return block.TestDisconnectBlock(txdb, mapTestPool); }
bool TestConnectBlock(CTxDB& txdb, map& mapTestPool) { CBlock block; if (!block.ReadFromDisk(nFile, nBlockPos, true)) return false; return block.TestConnectBlock(txdb, mapTestPool); }
bool DisconnectBlock() { CBlock block; if (!block.ReadFromDisk(nFile, nBlockPos, true)) return false; return block.DisconnectBlock(); }
bool ConnectBlock() { CBlock block; if (!block.ReadFromDisk(nFile, nBlockPos, true)) return false; return block.ConnectBlock(nFile, nBlockPos, nHeight); }
void print() const { printf("CBlockIndex(nprev=%08x, pnext=%08x, nFile=%d, nBlockPos=%d, nHeight=%d)\n", pprev, pnext, nFile, nBlockPos, nHeight); } };
void PrintTimechain();
// // Describes a place in the timechain to another node such that if the // other node doesn't have the same branch, it can find a recent common trunk. // The further back it is, the further before the branch point it may be. // class CBlockLocator { protected: vector vHave; public:
CBlockLocator() { }
explicit CBlockLocator(const CBlockIndex* pindex) { Set(pindex); }
explicit CBlockLocator(uint256 hashBlock) { map::iterator mi = mapBlockIndex.find(hashBlock); if (mi != mapBlockIndex.end()) Set((*mi).second); }
void Set(const CBlockIndex* pindex) { vHave.clear(); int nStep = 1; while (pindex) { CBlock block; block.ReadFromDisk(pindex, false); vHave.push_back(block.GetHash());
// Exponentially larger steps back for (int i = 0; pindex && i < nStep; i++) pindex = pindex->pprev; if (vHave.size() > 10) nStep *= 2; } }
CBlockIndex* GetBlockIndex() { // Find the first block the caller has in the main chain foreach(const uint256& hash, vHave) { map::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; if (pindex->IsInMainChain()) return pindex; } } return pindexGenesisBlock; }
uint256 GetBlockHash() { // Find the first block the caller has in the main chain foreach(const uint256& hash, vHave) { map::iterator mi = mapBlockIndex.find(hash); if (mi != mapBlockIndex.end()) { CBlockIndex* pindex = (*mi).second; if (pindex->IsInMainChain()) return hash; } } return hashGenesisBlock; }
int GetHeight() { CBlockIndex* pindex = GetBlockIndex(); if (!pindex) return 0; return pindex->nHeight; } };
extern map mapTransactions; extern map mapWallet; extern vector > vWalletUpdated; extern CCriticalSection cs_mapWallet; extern map, CPrivKey> mapKeys; extern map > mapPubKeys; extern CCriticalSection cs_mapKeys; extern CKey keyUser;
Read this went the opposite way
Go1dfish undelete link
unreddit undelete link
Author: fukya40
submitted by removalbot to removalbot [link] [comments]

"Bitcoin is Turing Complete as a system" and "OP_DATASIGVERIFY is recursion" - is it nonsense? Mr. Clemens Ley, Amaury Séchet?

It seems to me that all this "Bitcoin is Turing Complete as a system" and "OP_DATASIGVERIFY is recursion and is similar to OP_EVAL" doesn't make any sense.
If that makes sense then piece of paper is also "Turing complete" as a system (see #8).
CSW is incorrect to say that OP_DATASIGVERIFY is a recursion (see #10, 11)
This is addressed to Mr. Clemens Ley or anyone who understands the Clemens Ley's presentation "Turing Complete Computation in Bitcoin" in detail.
First of all here are two links:
Clemens Ley "Turing Complete Computation in Bitcoin" presentation here
CSW comments here (10-12 minute mark)
Mr. Ley:
1) Is my understanding correct that the "instruction set" that you show at 11:00 mark is not executed in Bitcoin, but rather on some other software that is not Bitcoin, that Alice and Bob both can run?
2) Is it correct that you only store the step-by-step log of execution on a blockchain, basically a text log file, so to say, even if in "tree-like" manner?
Because, (at 16:29) the script does following:
take 3, ignore it, take 1, ignore it, take q1, ignore it, check signature of this whole transaction via 2-of-2 multisig..
It's basically 2-of-2 multisig signing a text, not executing any operations.
3) Why do you need this complex tree-like structure of 16 transactions at 16:06, when the same message can be encoded in much less transactions (1?) like this:
Output 1: OP_RETURN "0,#|1,0|2,0|3,1|4,1,q1|5,#||3,1,q1|4,0||2,0,q1" (220 chars limit)
Output 2: OP_RETURN "3,0||1,0,q2" (is just to show what to do with 220 chars limit)
And only IF message is too long for 1 transaction:
Output 3: Pay to script hash of {next transaction}
Why do we need to send 16 transactions where 1 would be sufficient?
4) At 16:06 we have "0,#" transaction (lets call it "T1") and "0,#,q2+1,0" ("T2") and final "0,# + 1,0,acc" ("T3").
If all of them (according to 16:19 mark) are multisig transactions - then they are all P2SH ("pay to script hash").
So, in order for Alice to sign T1, the transaction needs to include signature of script of T2.
Does Alice see T2 beforehand or does she sign it blindly?
The question is because if she signs it blindly - then Bob can cheat and give her a hash of some script that pays to himself, end of story.
Bob gets 1 BTC and did't need to do any computation.
In other case if Bob shows T2 to Alice beforehand, then it means that Bob needs to show all transactions to Alice before she signs them. In that case Alice has all she needs and cheats Bob and not pays.
What am I missing here?
5) Where does 1 BTC as input goes to? To T1? Or to T3 (final transaction)?
There are really 4 variation of a question here, depending on answer to #4 and #5, but in many of them either Bob or Alice could cheat, especially if 1 BTC goes to T3 and Alice signs T3 first.. Or if 1 BTC goes to T1 and Alice signs T1 first not seeing T2 (only hash of T2). If Alice sees all transactions before signing - then she doesn't even need to pay.
6) At 16:14 mark there is a transaction "5,#", it's output doesn't go anywhere.
At 18:30 you tell that the system is protected because the inputs are used in outputs.
But "5,#" transaction is not used as inputs anywhere.
Does this "protection" argument make sense?
7) In the previous example at 5:33 "X" was the input to the transaction, which really guaranteed that script executed with this "X" would allow you to spend BCH. Which is definitely correct.
At around 7:10 you tell that "Encoding of X" should be revealed by Bob.
What is "Encoding of X" in this case?
Is it the "initial state of Turing machine" in form of unsigned transcations? If so - how is Bob guaranteed to be paid? Alice has all she needs (instruction set and initial state) and cheats - goes away.
Or is it the "log of a step-by-step execution" of this instruction set on other software? Again. Alice cheats and runs.
It doesn't seem to be something else, because all the scripts that are shown at 16:28 have no data to work on. They are complete. Bob has nothing to prepend here to make those scripts "execute". They are self-sufficient - a string and a multisig signature check, no other data is needed.
8) So, if it is actually some other software that runs the Turing complete code - does that mean that a piece of signed paper and human is also Turing complete as a system?
A human starts to write same step-by-step state changes that some other software ran and signs the paper...
It doesn't seem correct to call "piece of paper" Turing complete "as a system".
Bitcoin in this presentation is no more than "piece of signed paper". It contains just a log of state of execution.
If we can't call "piece of signed paper" Turing complete - why do we call Bitcoin Turing complete?
9) About the CSW interview (probably more to u/deadalnix or whoever is in charge of Bitcoin ABC tech now)
At 10 minute mark CSW claims (especially at 10:59) that we can "take a digital signature that "links" to another digital signature .. in DATASIGVERIFY".
He seems to imply that we sign data that contains ID of another transaction. I have no other explanation what "link" he means otherwise.
CSW (at 11:49) exact quote: "So you actually have script conditionals linking multiple transactional outputs that you embed into one transaction linking other possible transaction states, which effectively becomes recursion"
He seems to imply that Bitcoin ABC's OP_DATASIGVERIFY would be "understanding" what "data" it is signing. Which is incorrect.
OP_DATASIGVERIFY is oblivious to what is the "data" that it signs, correct?
10) So it doesn't become "recursion" as CSW claims UNLESS there is some other software, that is not Bitcoin that executes this "data" and/or executes OP_DATASIGVERIFY in a different way than Andrew Stone of Bitcoin Unlimited proposed here and also it's different from the way Bitcoin ABC implements it.
And it also has nothing to do with OP_EVAL (as he claims next), because OP_DATASIGVERIFY cannot evaluate anything.
OP_DATASIGVERIFY signs the data (string, text, binary blob), checks if signature is correct. If it is correct - it goes to next instruction, in other case it ends the script and user cannot spend the output (money).
So, CSW is incorrect to call it "recursion", right?
11) Would it be correct to say that CSW fantasizes about how OP_DATASIGVERIFY works and it has nothing to do with the way actual OP_DATASIGVERIFY works?
cc cryptorebel because all of my research started with his interesting discussion with zectro here
Can somebody please ping Mr. Clemens Ley if he's on reddit?
Or maybe at least Mr. Ryan X. Charles (who I assume is his boss?)
I don't know their handles.
submitted by fromaratom to btc [link] [comments]

How to safely split and send bcash from Bitcoin Core

I have some BTC in cold storage on an offline laptop.
I wanted to split off my Bcash to dump it, but didn't want to install megabytes of un-audited bitcoin-abc code on my cold storage laptop.
So I was wondering how to go about signing a raw transaction on the offline laptop without having to install piles of possibly trojaned code there.
I eventually came up with this small patch to Bitcoin Core v1.4.2 which allows me to sign a transaction with the SIGHASH_FORKID flag simply by using CASH as the sighashtype (optional 4th argument) when running signrawtransaction:
diff --git a/src/core_write.cpp b/src/core_write.cpp index b0993a1..42b0d42 100644 --- a/src/core_write.cpp +++ b/src/core_write.cpp @@ -61,6 +61,7 @@ const std::map mapSigHashTypes = (static_cast(SIGHASH_NONE|SIGHASH_ANYONECANPAY), std::string("NONE|ANYONECANPAY")) (static_cast(SIGHASH_SINGLE), std::string("SINGLE")) (static_cast(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY), std::string("SINGLE|ANYONECANPAY")) + (static_cast(SIGHASH_ALL|SIGHASH_FORKID), std::string("CASH")) ; /** diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 0fabb9f..e7330f7 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -631,6 +631,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) " \"ALL|ANYONECANPAY\"\n" " \"NONE|ANYONECANPAY\"\n" " \"SINGLE|ANYONECANPAY\"\n" + " \"CASH\"\n" "\nResult:\n" "{\n" @@ -800,6 +801,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) (string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)) (string("SINGLE"), int(SIGHASH_SINGLE)) (string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)) + (string("CASH"), int(SIGHASH_ALL|SIGHASH_FORKID)) ; string strHashType = request.params[3].get_str(); if (mapSigHashValues.count(strHashType)) @@ -808,7 +810,7 @@ UniValue signrawtransaction(const JSONRPCRequest& request) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid sighash param"); } - bool fHashSingle = ((nHashType & ~SIGHASH_ANYONECANPAY) == SIGHASH_SINGLE); + bool fHashSingle = ((nHashType & ~(SIGHASH_ANYONECANPAY | SIGHASH_FORKID)) == SIGHASH_SINGLE); // Script verification errors UniValue vErrors(UniValue::VARR); diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index f9b7835..080bc44 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -187,7 +187,7 @@ bool static IsDefinedHashtypeSignature(const valtype &vchSig) { if (vchSig.size() == 0) { return false; } - unsigned char nHashType = vchSig[vchSig.size() - 1] & (~(SIGHASH_ANYONECANPAY)); + unsigned char nHashType = vchSig[vchSig.size() - 1] & (~(SIGHASH_ANYONECANPAY | SIGHASH_FORKID)); if (nHashType < SIGHASH_ALL || nHashType > SIGHASH_SINGLE) return false; @@ -1177,7 +1177,7 @@ PrecomputedTransactionData::PrecomputedTransactionData(const CTransaction& txTo) uint256 SignatureHash(const CScript& scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType, const CAmount& amount, SigVersion sigversion, const PrecomputedTransactionData* cache) { - if (sigversion == SIGVERSION_WITNESS_V0) { + if (sigversion == SIGVERSION_WITNESS_V0 || (nHashType & SIGHASH_FORKID)) { uint256 hashPrevouts; uint256 hashSequence; uint256 hashOutputs; diff --git a/src/script/interpreter.h b/src/script/interpreter.h index 79894c5..414e23e 100644 --- a/src/script/interpreter.h +++ b/src/script/interpreter.h @@ -24,6 +24,7 @@ enum SIGHASH_ALL = 1, SIGHASH_NONE = 2, SIGHASH_SINGLE = 3, + SIGHASH_FORKID = 0x40, SIGHASH_ANYONECANPAY = 0x80, }; 
it only involves editing 7 lines, so can easily be applied by hand to your offline machine if necessary.
To test it, here I create and sign a raw transaction using Bitcoin ABC, and then create and sign the same transaction using my patched Bitcoin Core, with the new 'CASH' signature type:
$ hex=$(bch signrawtransaction \ $(bch createrawtransaction \ '[{"txid":"'$txid'","vout":'$vout'}]' \ '{"'$dest'":'$amount'}') \ '[{"txid":"'$txid'","vout":'$vout',"scriptPubKey":"'$pubkey'"}]' \ '["'$priv'"]' | grep hex | cut -d'"' -f4) $ bcc signrawtransaction \ $(bcc createrawtransaction \ '[{"txid":"'$txid'","vout":'$vout'}]' \ '{"'$dest'":'$amount'}') \ '[{"txid":"'$txid'","vout":'$vout',"scriptPubKey":"'$pubkey'"}]' \ '["'$priv'"]' \ CASH | sed "s/$hex/same/" { "hex": "same", "complete": true } 
(bcc is my alias for bitcoin core, and bch is my alias for bitcoin cash)
The resulting signed transaction is byte-for-byte identical.
Hopefully this is useful for others.
I notice that the signing code used for SIGHASH_FORKID is the same as for SIGVERSION_WITNESS_V0, but I don't think that's a problem even after SegWit activates. I tried replaying a testnet Bcash transaction on the BTC testnet (where SegWit is active) and saw:
An error occured: 16: mandatory-script-verify-flag-failed (Signature hash type missing or not understood). Code:-26 
submitted by dooglus to Bitcoin [link] [comments]

Practicing functions and loops, could I have done this better in anyway?

Hello everyone,
Just looking for some constructive criticism, I'm 7 weeks into my first C++ course.
//Boiler plate #include  #include  #include  using namespace std; //FILLER PROTO void WelcomeMessage(); //MENU PROTO void MainMenu(unsigned short & coinChoice); void CoinSwitch(unsigned short coinChoice); //CoinSwitch(CASES_1-3) void CaseOne(); void CaseTwo(); void CaseThree(); //Utilities(ERRORS) PROTO void CoinChoiceError(unsigned short & coinChoice); //Utilities(LOOPS) PROTO void SelectAnotherCoin(char & cont); //Main int main() { //Main Start //Variables unsigned short coinChoice = 0; char cont = 'y'; //Constants //Main Loop while (cont == 'y' || cont == 'Y') {//Start of main loop //Welcome Message WelcomeMessage(); //Main Menu MainMenu(coinChoice); //coinChoice Error CoinChoiceError(coinChoice); //Coin Switch into Sub Menu CoinSwitch(coinChoice); //LoopCheck SelectAnotherCoin(cont); if (cont == 'n' || cont == 'N') {//Start of Continue if return 0; }//End of Continue if }//End of main loop } // Main End //!!FILLER BLOCK!! void WelcomeMessage() { //Welcome Start cout << setw(10) << "\n~~~~~~~~~~" << setw(7) << "Welcome" << setw(10) << "~~~~~~~~~~" << endl; cout << setw(52 / 2) << "Cryptocurrency Simulation" << endl; cout << setw(10) << "~~~~~~~~~~" << setw(7) << "~~~~~~~" << setw(10) << "~~~~~~~~~~" << endl << endl; } //Welcome End //!!MENU BLOCK!! void MainMenu(unsigned short & coinChoice) { //Main Menu Start cout << setw(49 / 2) << "~Choose Your Currency~" << endl; cout << setw(12 / 2) << "1." << setw(7) << " ------" << setw(17 / 2) << "Bitcoin" << endl; cout << setw(12 / 2) << "2." << setw(7) << " ------" << setw(18 / 2) << "Ethereum" << endl; cout << setw(12 / 2) << "3." << setw(7) << " ------" << setw(18 / 2) << "Litecoin" << endl << endl; cout << "Your answer (1-3): "; cin >> coinChoice; cout << endl; } //Main Menu End void CoinSwitch(unsigned short coinChoice) {//Coin Switch Start switch(coinChoice) {//Switch Start case 1://case 1 start CaseOne(); break;//case 1 end case 2://case 2 start CaseTwo(); break;//case 2 end case 3://case 3 start CaseThree(); break;//case 3 end }//Switch End }//Coin Switch End //CoinSwitch CASES void CaseOne() {//CaseOne Start cout << " -You've selected Bitcoin!-\n\n"; }//CaseOne End void CaseTwo() {//CaseTwo Start cout << "-You've selected Ethereum!-\n\n"; }//CaseTwo End void CaseThree() {//CaseThree Start cout << "-You've selected Litecoin!-\n\n"; }//CaseThree End //!!UTILITIES BLOCK!! void CoinChoiceError(unsigned short & coinChoice) {//CoinChoiceError start while (coinChoice > 3) {//coinChoice while start cout << "*********************************" << endl; cout << "*!!Please enter a valid number!!*" << endl; cout << "*********************************" << endl << endl; MainMenu(coinChoice); cin >> coinChoice; }//coinChoice while end }//CoinChoiceError end void SelectAnotherCoin(char & cont) {//SelectAnotherCoin Start cout << "Would you like to select another coin? (Y/N)\n"; cout << "Your answer: "; cin >> cont; if (cont != 'y' && cont != 'Y') {//Start of cont if while (cont != 'n' && cont != 'N') {//Start of Continue Loop cout << "\n************************************" << endl; cout << "*!!Please enter a valid Character!!*" << endl; cout << "************************************" << endl << endl; cout << "Your answer (Y/N): "; cin >> cont; }//End of Continue Loop }//End of cont if }//SelectAnotherCoin End 
submitted by Doge_Mike to cpp_questions [link] [comments]

What the?.. (bitcoin gold's source code)

I am looking at the Bitcoin Gold official source code and either I am missing something or it can't even work? unsigned char nHashType = GetHashType(vchSig) & (~(SIGHASH_ANYONECANPAY | SIGHASH_FORKID));
if (nHashType < SIGHASH_ALL || nHashType > SIGHASH_SINGLE) return false;
How can this ever be true if SIGHASH_ANYONECANPAY = 0x80 and SIGHASH_FORKID = 0x4F?! The mask gives you 0x30, this means the value can't possibly be in the range [1,3]!
This means that whenever the code verifies the signature it will always fail?
What am I missing here? Was anybody able to transact with that scam at all?
EDIT: Never mind, solved.
submitted by NxtChg to btc [link] [comments]

Hardware Wallet Standard | Jonas Schnelli | Aug 16 2016

Jonas Schnelli on Aug 16 2016:
Unfortunately, there is no standard in how desktop- or mobile-wallets
can interact with a hardware device resulting in wallet vendors adding
plugins with proprietary code for non-standardized interfaces.
I started a BIP (extreme draft, feel free to improve language, grammar
and content) to address this missing part of the ecosystem.
I think it would be extremely helpful if @ledger, @trezor,
@voisin/@breadwallet, @electrum, @bitpay (and more?!) would help working
on a such standard.
The BIP describes two approaches how to communicate (pipe and
URI-scheme) with the signing-devices app, although, in my opinion, all
major platform do support the URI approach (maybe we could drop the pipe
approach then).
The URI approach means that there is no need to configure the
application location in order to start a inter-process(-app) communication.
---- BIP (rough early stage draft)
BIP: ???
Title: Detached Signing
Author: Jonas Schnelli
Status: Draft (early stage!)
Type: Standards Track
Created: 2016-08-02
== Abstract ==
This BIP describes a way how wallet applications can decouple sensitive
privatekeys from the internal keychain and interact with a
signing-devices (hardware wallet, "cold" storage) over a generic
interface in order to get signatures.
== Motivation ==
It seems like that the current approach for allowing signing-devices to
interact with third party wallets is to build a plugin [1][2][3]. Adding
plugins for each hardware wallet type will increase possible security
issues and result in multiple proprietary-third-party code within the
wallet application with very similar structures.
A generic interface how wallets can interact with signing-devices would
result in better user experience, less critical code and simpler
adaption for various signing-devices.
== Specification ==
In order to support desktop- and smartphone-wallet-applications, this
BIP describes two slightly different approaches (process pipe and URI
call) in how to interact with the signing-devices. If possible, the
modern URI approach should be chosen.
=== Signing-Device-Controller-Application ===
To allow a generic interface while still allowing different ways how to
internally communicate with the signing device itself (USB, TCP/IP,
air-gapped Qr-Code scanning, etc.) a controller-application is required.
=== General signing process ===
The wallets signing process must be according the following principal:
or message together with metadata (scriptPubKey, hd-keypath of the inputs)
signing-request-object, eventually shows UI, user can sign or cancel
signing-response-object with signatures or an error
creating process (example: add signatures to transaction and broadcast)
=== Desktop Process Intercommunication ===
Desktop wallets can interact with a signing device over process
intercommunication (pipe) together with a
As specified below, the signing-request-object is a URI string passed
through the pipe. The desktop wallet needs to wait (with a recommended
timeout between 1 and 5 minutes) until the signing-response-object will
be sent back by the signing-device-controller-application.
=== Smartphone/URI App Intercommunication ===
Smartphones and modern operating systems are trying to sandbox
applications and interprocess communication (on pipe level) is mostly
On smartphones, we must use URI-schemes.
The wallet can pass information to the
signing-device-controller-application by using a predefined URI scheme.
The querystring must be URI encoded.
RFC 2616 does not specify a maximum length of URIs (get request). Most
modern smartphone operating system allow URIs up to serval megabytes.
Signing complex data-structure is therefore possible.
The returnurischeme must contain a URI schema where the
result of the signing process should be returned to.
The returnurischeme must be populated and "opened" once the signing
process has been completed (or cancled).
=== Signing Request ===
The signing request is a flexible URI-Query-String that will be used by
the Signing-device-controller-application for user confirmation as well
as for creating the signature.
The URI-query-string must conform to the following format:
type = type of the data to sign
data = raw unsigned bitcoin transaction or text-message
(optional)inputscripts = scriptPubKey(s) of the inputs in exact order
(optional)inputhdkeypath = hd-keypath of the inputs in exact order
(optional)returnscheme = a URI scheme where the response must be sent to
(smartphone approach)
  • inputhdkeypath or inputscripts must be provided.
=== Signing Response ===
The signing response is a flexible URI-Query-String that will be sent
back to the wallet application and must contain the signatures or an
error code.
The URI-query-string can be opened (smartphone approach) or will be sent
back though the interprocess pipe.
In case of ECDSA, the returned signatures must be normalized compact
signatures with the size of 64bytes (128 hex chars).
==== Possible error code ====
0 = no error
1 = user canceled
2 = timeout
10 = missing key identifier (missing HD keypath or input scriptpubkey)
11 = unsupported signing type
12 = could not resolve script
50 = unknown internal error
==== Examples ====
===== Simple p2pkh transaction =====
Unsigned raw transaction:
(input ced97f90d7d10a767dfd2bed769ac42cc48be1d3e648f1bfb5dbb70f9dd13cfd
vout:1, output: P2PKH mtgQ54Uf3iRTc9kq18rw9SJznngvF5ryZn 1 BTC)
signing-request URI must be:
The inputhdkeypath is optional in this case
signing-response URI must be:
===== Simple a bitcoin message =====
Message: Lorem ipsum dolor sit amet
signing-request URI must be:
signing-response URI must be:
=== Support for multiple signing-devices ===
Must operating systems allow only one registered application per
URI-scheme. To support multiple signing-devices, wallets and
signing-devices can optional add support for brand based URI-schemes.
In addition to the standard URI scheme,
signing-devices-controller-applications can register an additional URI
scheme (with the identical request/response syntax and logic) including
a brand-identifier.
Registering a brand-identifier based URI scheme without registering the
default URI scheme is not allowed.
Wallets can detect if a certain brand based URI scheme is supported and
therefore gives user a selection if multiple signing-devices where
detected [4][5].
Supported brand-identifiers are:
  • trezor
  • ledger
  • keepkey
  • digitalbitbix
== References ==
== Acknowledgements ==
== Copyright ==
This work is placed in the public domain.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
submitted by dev_list_bot to bitcoin_devlist [link] [comments]

Would anyone object to adding a dlopen message hook system? | Erik Aronesty | Aug 13 2017

Erik Aronesty on Aug 13 2017:
I was thinking about something like this that could add the ability for
module extensions in the core client.
When messages are received, modules hooks are called with the message data.
They can then handle, mark the peer invalid, push a message to the peer or
pass through an alternate command. Also, modules could have their own
private commands prefixed by "x:" or something like that.
The idea is that the base P2P layer is left undisturbed, but there is now a
way to create "enhanced features" that some peers support.
My end goal is to support using lightning network micropayments to allow
people to pay for better node access - creating a market for node services.
But I don't think this should be "baked in" to core. Nor do I think it
should be a "patch". It should be a linked-in module, optionally compiled
and added to bitcoin conf, then loaded via dlopen(). Modules should be
slightly robust to Bitcoin versions changing out from under them, but not
if the network layer is changed. This can be ensured by a) keeping a
module version number, and b) treating module responses as if they were
just received from the network. Any module incompatibility should throw
an exception...ensuring broken peers don't stay online.
In general I think the core reference would benefit from the ability to
create subnetworks within the Bitcoin ecosystem. Right now, we have two
choices... full node and get slammed with traffic, or listen-only node, and
do nothing.
Adding a module/hook system would allow a complex ecosystem of
participation - and it would seem to be far more robust in the long term.
Something like this???
class MessageHookIn {
int hookversion; int64_t nodeid; int nVersion; int64_t serviceflags; const char *strCommand; const char *nodeaddr; const char *vRecv; int vRecvLen; int64_t nTimeReceived; 
class MessageHookOut {
int hookversion; int misbehaving; const char *logMsg; const char *pushCommand; const unsigned char *pushData; int pushDataLen; const char *passCommand; CDataStream passStream; 
class MessageHook {
int hookversion; std::string name; typedef bool (*HandlerType)(const MessageHookIn *in, MessageHookOut 
HandlerType handle; 
-------------- next part --------------
An HTML attachment was scrubbed...
submitted by dev_list_bot to bitcoin_devlist [link] [comments]

Setting up bitcoin-abe for defcoin

here's my notes on installing abe for blockchain explorer. YMMV ;)
14.04 ubuntu sudo apt-get install screen build-essential libssl-dev libboost1.55-all-dev libdb5.3-dev libdb5.3++-dev libminiupnpc-dev mysql-client mysql-server git clone cd defcoin/src make -f makefile.unix cp defcoind ~/ edit ~/.defcoin/defcoin.conf ==defcoin.conf== rpcuser=someuser rpcpassword=somepassword alertnotify=echo %s | mail -s "defcoin Alert" [email protected] txindex=1 ================ run screen start defcoind ~/defcoind -reindex detach (ctrl-a-d) sudo apt-get install python2.7 python-crypto python-mysqldb git clone (see ) create mysql user & database cd bitcoin-abe find magic number main.cpp of defcoin unsigned char pchMessageStart[4] = { 0xfb, 0xc0, 0xb6, 0xdb }; // defcoin: increase each by adding 2 to bitcoin's value. find address version edit abe.conf ==abe.conf== default-loader = blkfile dbtype MySQLdb connect-args {"user":"abe","db":"abe","passwd":"somepassword"} port 2750 host upgrade datadir += [{ "dirname": "/home/user1234/.defcoin", "code3": "DFC", "address_version": "\u001e", "magic": "xfbxc0xb6xdb", "chain": "Defcoin" }] =========== 
Load abe data
python -m Abe.abe --config=/path/to/abe.conf --commit-bytes 100000 --no-serve 
Rescan abe data (if needeD)
python -m Abe.abe --config=/path/to/abe.conf --rescan 
Run web server
python -m Abe.abe --config=/path/to/abe.conf 
should be up and listening on port 2750.
submitted by embalmed to defcoin [link] [comments]

Signed/Unsigned Char Data types with Program  #47 Unsigned Character 1.0.4 gameplay - YouTube Live: Bitcoin (BTC) to Dollar chart 1 minute Real time ... 05A.1 Beispiele Zweierkomplement, Überlauf, signed und unsigned unsigned char, unsigned int, unsigned long

Bitcoin address generator. GitHub Gist: instantly share code, notes, and snippets. Skip to content. All gists Back to GitHub. Sign in Sign up Instantly share code, notes, and snippets. 0xa / bitcoinaddrgen.cpp. Created Apr 14, 2013. Star 0 Fork 0; Code Revisions 1. Embed. What would you like to do? Embed Embed this gist in your website. Share Copy sharable link for this gist. Clone via HTTPS ... Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up. Sign up to join this community . Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Bitcoin . Home ; Questions ; Tags ; Users ; Unanswered ; Jobs; Implementation of the Variable length integer in C. Ask Question Asked 3 ... Version 1 was introduced in the genesis block (January 2009). Version 2 was introduced in Bitcoin Core 0.7.0 (September 2012) as a soft fork. As described in BIP34, valid version 2 blocks require a block height parameter in the coinbase. Bitcoin Core is supported and extensively tested on operating systems using the Linux kernel, macOS 10.10+, and Windows 7 and newer. It is not recommended to use Bitcoin Core on unsupported systems. Bitcoin Core should also work on most other Unix-like systems but is not as frequently tested on them. unsigned char <= 72 : Die Signatur für den Proof-of-Stake wird hier angegeben. Transaktion . Eine Transaktion ist ein signierter Datenabschnitt, der an das Netzwerk gesendet und in Blöcken gesammelt wird. Es verweist typischerweise auf vorherige Transaktionen und weist eine bestimmte Anzahl von 42 davon einem oder mehreren neuen öffentlichen Schlüsseln zu. Derzeit sind einige Transaktionst

[index] [7824] [35661] [21306] [22185] [22942] [40772] [3468] [37634] [44863] [16938]

Signed/Unsigned Char Data types with Program #47

We use char data types for working with characters or strings... In this video I explained about the two types of char data type i.e. signed & unsigned with ... But how does bitcoin actually work? ... Programming in C: Lesson 11 - Short, long, int, unsigned, char variables and sizeof() - Duration: 7:13. swarmotics 9,454 views. 7:13. How to Make Teaching ... For the Love of Physics - Walter Lewin - May 16, 2011 - Duration: 1:01:26. Lectures by Walter Lewin. They will make you ♥ Physics. Recommended for you This is your beginners guide on how to invest in bitcoin and how to invest in cryptocurrency in 2020. In this video, we will cover how to get started with cr... For Free Live Chart from all crypto or to Buy and Sell click on the link: Live: Bitcoin (BTC) to Dollar char...