当前位置: 首页>>代码示例>>C++>>正文


C++ Watcher::find_tx方法代码示例

本文整理汇总了C++中Watcher::find_tx方法的典型用法代码示例。如果您正苦于以下问题:C++ Watcher::find_tx方法的具体用法?C++ Watcher::find_tx怎么用?C++ Watcher::find_tx使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Watcher的用法示例。


在下文中一共展示了Watcher::find_tx方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: gather_challenges

bool gather_challenges(unsigned_transaction& utx, Watcher& watcher)
{
    utx.challenges.resize(utx.tx.inputs.size());

    for (size_t i = 0; i < utx.tx.inputs.size(); ++i)
    {
        bc::input_point& point = utx.tx.inputs[i].previous_output;
        if (!watcher.db().has_tx(point.hash))
            return false;
        bc::transaction_type tx = watcher.find_tx(point.hash);
        utx.challenges[i] = tx.outputs[point.index].script;
    }

    return true;
}
开发者ID:snash779,项目名称:airbitz-core,代码行数:15,代码来源:Inputs.cpp

示例2: ABC_ERROR

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();
}
开发者ID:TSchnaars,项目名称:airbitz-core,代码行数:16,代码来源:WatcherBridge.cpp

示例3: ABC_ERROR

Status
signTx(bc::transaction_type &result, Watcher &watcher, const KeyTable &keys)
{
    for (size_t i = 0; i < result.inputs.size(); ++i)
    {
        // Find the utxo this input refers to:
        bc::input_point& point = result.inputs[i].previous_output;
        bc::transaction_type tx = watcher.find_tx(point.hash);

        // Find the address for that utxo:
        bc::payment_address pa;
        bc::script_type& script = tx.outputs[point.index].script;
        bc::extract(pa, script);
        if (payment_address::invalid_version == pa.version())
            return ABC_ERROR(ABC_CC_Error, "Invalid address");

        // Find the elliptic curve key for this input:
        auto key = keys.find(pa.encoded());
        if (key == keys.end())
            return ABC_ERROR(ABC_CC_Error, "Missing signing key");
        bc::ec_secret secret = libwallet::wif_to_secret(key->second);
        bc::ec_point pubkey = bc::secret_to_public_key(secret,
            libwallet::is_wif_compressed(key->second));

        // Gererate the previous output's signature:
        // TODO: We already have this; process it and use it
        script_type sig_script = outputScriptForPubkey(pa.hash());

        // Generate the signature for this input:
        hash_digest sig_hash =
            script_type::generate_signature_hash(result, i, sig_script, 1);
        if (sig_hash == null_hash)
            return ABC_ERROR(ABC_CC_Error, "Unable to sign");
        data_chunk signature = sign(secret, sig_hash,
            create_nonce(secret, sig_hash));
        signature.push_back(0x01);

        // Create out scriptsig:
        script_type scriptsig;
        scriptsig.push_operation(create_data_operation(signature));
        scriptsig.push_operation(create_data_operation(pubkey));
        result.inputs[i].script = scriptsig;
    }

    return Status();
}
开发者ID:snash779,项目名称:airbitz-core,代码行数:46,代码来源:Inputs.cpp


注:本文中的Watcher::find_tx方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。