Example #1
0
Status
randomData(DataChunk &result, size_t size)
{
    DataChunk out;
    out.resize(size);

    if (!RAND_bytes(out.data(), out.size()))
        return ABC_ERROR(ABC_CC_Error, "Random data generation failed");

    result = std::move(out);
    return Status();
}
Example #2
0
Status
watcherBridgeRawTx(Wallet &self, const char *szTxID,
    DataChunk &result)
{
    Watcher *watcher = nullptr;
    ABC_CHECK(watcherFind(watcher, self));

    bc::hash_digest txid;
    if (!bc::decode_hash(txid, szTxID))
        return ABC_ERROR(ABC_CC_ParseError, "Bad txid");
    auto tx = watcher->find_tx(txid);
    result.resize(satoshi_raw_size(tx));
    bc::satoshi_save(tx, result.begin());

    return Status();
}