本文整理汇总了C++中CMutableTransaction::SetNamecoin方法的典型用法代码示例。如果您正苦于以下问题:C++ CMutableTransaction::SetNamecoin方法的具体用法?C++ CMutableTransaction::SetNamecoin怎么用?C++ CMutableTransaction::SetNamecoin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMutableTransaction
的用法示例。
在下文中一共展示了CMutableTransaction::SetNamecoin方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: JSONRPCError
/**
* Implement the rawtx name operation feature. This routine interprets
* the given JSON object describing the desired name operation and then
* modifies the transaction accordingly.
* @param tx The transaction to extend.
* @param obj The name operation "description" as given to the call.
*/
void
AddRawTxNameOperation (CMutableTransaction& tx, const UniValue& obj)
{
UniValue val = find_value (obj, "op");
if (!val.isStr ())
throw JSONRPCError (RPC_INVALID_PARAMETER, "missing op key");
const std::string op = val.get_str ();
if (op != "name_update")
throw JSONRPCError (RPC_INVALID_PARAMETER,
"only name_update is implemented for the rawtx API");
val = find_value (obj, "name");
if (!val.isStr ())
throw JSONRPCError (RPC_INVALID_PARAMETER, "missing name key");
const valtype name = ValtypeFromString (val.get_str ());
val = find_value (obj, "value");
if (!val.isStr ())
throw JSONRPCError (RPC_INVALID_PARAMETER, "missing value key");
const valtype value = ValtypeFromString (val.get_str ());
val = find_value (obj, "address");
if (!val.isStr ())
throw JSONRPCError (RPC_INVALID_PARAMETER, "missing address key");
const CBitcoinAddress toAddress(val.get_str ());
if (!toAddress.IsValid ())
throw JSONRPCError (RPC_INVALID_ADDRESS_OR_KEY, "invalid address");
const CScript addr = GetScriptForDestination (toAddress.Get ());
tx.SetNamecoin ();
/* We do not add the name input. This has to be done explicitly,
but is easy from the name_show output. That way, createrawtransaction
doesn't depend on the chainstate at all. */
const CScript outScript = CNameScript::buildNameUpdate (addr, name, value);
tx.vout.push_back (CTxOut (NAME_LOCKED_AMOUNT, outScript));
}