00814e24f9
The usage of a ripe160 for bitcoin addresses in the API and in the Indexer loses some info, specifically what kind of script it is. Additionally not all types of scripts fit this mold. At best that means its not future-proof. This adds a method to the API in order to select from a Tx the hashed outscript (thats singlehashed sha256) and refactor the address indexer to use that instead of the ripe160 address. The API enums broke a little, so I used the opportunity to break it a lot and clean up the enums in order to make them more future-proof. But, yeah, software from before this commit is protocol incompatible with software after this commit.
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2014 The Bitcoin Core developers
|
|
* Copyright (C) 2019 Tom Zander <tomz@freedommail.ch>
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef FLOWEE_CRYPTO_SHA256_H
|
|
#define FLOWEE_CRYPTO_SHA256_H
|
|
|
|
#include <cstdint>
|
|
#include <cassert>
|
|
#include <string>
|
|
|
|
/** A hasher class for SHA-256. */
|
|
class CSHA256
|
|
{
|
|
private:
|
|
uint32_t s[8];
|
|
unsigned char buf[64];
|
|
uint64_t bytes;
|
|
|
|
public:
|
|
static const size_t OUTPUT_SIZE = 32;
|
|
|
|
CSHA256();
|
|
inline CSHA256& Write(const char* data, int len) {
|
|
assert(len >= 0);
|
|
return Write(reinterpret_cast<const unsigned char*>(data), size_t(len));
|
|
}
|
|
CSHA256& Write(const unsigned char* data, size_t len);
|
|
inline void Finalize(char *hash) {
|
|
return Finalize(reinterpret_cast<unsigned char*>(hash));
|
|
}
|
|
void Finalize(unsigned char *hash);
|
|
CSHA256& Reset();
|
|
};
|
|
|
|
/** Autodetect the best available SHA256 implementation.
|
|
* Returns the name of the implementation.
|
|
*/
|
|
std::string SHA256AutoDetect();
|
|
|
|
/** Compute multiple double-SHA256's of 64-byte blobs.
|
|
* output: pointer to a blocks*32 byte output buffer
|
|
* input: pointer to a blocks*64 byte input buffer
|
|
* blocks: the number of hashes to compute.
|
|
*/
|
|
void SHA256D64(unsigned char* output, const unsigned char* input, size_t blocks);
|
|
|
|
#endif
|