Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 28dede7

Browse files
committedApr 2, 2019
issueasset contract_hash arg, default of generated key in wallet
1 parent a904f02 commit 28dede7

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed
 

‎src/wallet/rpcwallet.cpp

+16-4
Original file line numberDiff line numberDiff line change
@@ -5713,21 +5713,23 @@ UniValue issueasset(const JSONRPCRequest& request)
57135713
return NullUniValue;
57145714
}
57155715

5716-
if (request.fHelp || request.params.size() < 2 || request.params.size() > 3)
5716+
if (request.fHelp || request.params.size() < 2 || request.params.size() > 4)
57175717
throw std::runtime_error(
57185718
"issueasset assetamount tokenamount ( blind )\n"
57195719
"\nCreate an asset. Must have funds in wallet to do so. Returns asset hex id.\n"
57205720
"\nArguments:\n"
57215721
"1. \"assetamount\" (numeric or string, required) Amount of asset to generate.\n"
57225722
"2. \"tokenamount\" (numeric or string, required) Amount of reissuance tokens to generate. These will allow you to reissue the asset if in wallet using `reissueasset`. These tokens are not consumed during reissuance.\n"
57235723
"3. \"blind\" (bool, optional, default=true) Whether to blind the issuances.\n"
5724+
"4. \"contract_hash\" (string, optional) 32-byte string to have asset id commit to.\n"
57245725
"\nResult:\n"
57255726
"{ (json object)\n"
57265727
" \"txid\":\"<txid>\", (string) Transaction id for issuance.\n"
57275728
" \"vin\":\"n\", (numeric) The input position of the issuance in the transaction.\n"
57285729
" \"entropy\":\"<entropy>\", (string) Entropy of the asset type.\n"
57295730
" \"asset\":\"<asset>\", (string) Asset type for issuance.\n"
57305731
" \"token\":\"<token>\", (string) Token type for issuance.\n"
5732+
" \"contract_hash\":<hex> (string) If no `contract_hash` was given as an argument, this will be the SHA256 image of a newly generated public key from your wallet. Can be used to prove authorship of issuance after the fact.\n"
57315733
"}\n"
57325734
"\nExamples:\n"
57335735
+ HelpExampleCli("issueasset", "10 0")
@@ -5771,17 +5773,26 @@ UniValue issueasset(const JSONRPCRequest& request)
57715773
token_dest_blindpub = pwallet->GetBlindingPubKey(GetScriptForDestination(token_dest));
57725774
}
57735775

5774-
uint256 dummyentropy;
5775-
CAsset dummyasset;
57765776
IssuanceDetails issuance_details;
5777+
5778+
if (!request.params[3].isNull()) {
5779+
issuance_details.contract_hash = ParseHashV(request.params[3], "contract_hash");
5780+
} else {
5781+
// Finally get contract hash key
5782+
if (!pwallet->GetKeyFromPool(newKey)) {
5783+
throw JSONRPCError(RPC_WALLET_KEYPOOL_RAN_OUT, "Error: Keypool ran out, please call keypoolrefill first");
5784+
}
5785+
issuance_details.contract_hash = newKey.GetHash();
5786+
}
5787+
57775788
issuance_details.blind_issuance = blind_issuances;
57785789
CTransactionRef tx_ref = SendGenerationTransaction(GetScriptForDestination(asset_dest), asset_dest_blindpub, GetScriptForDestination(token_dest), token_dest_blindpub, nAmount, nTokens, &issuance_details, pwallet);
57795790

57805791
// Calculate asset type, assumes first vin is used for issuance
57815792
CAsset asset;
57825793
CAsset token;
57835794
assert(!tx_ref->vin.empty());
5784-
GenerateAssetEntropy(issuance_details.entropy, tx_ref->vin[0].prevout, uint256());
5795+
GenerateAssetEntropy(issuance_details.entropy, tx_ref->vin[0].prevout, issuance_details.contract_hash);
57855796
CalculateAsset(asset, issuance_details.entropy);
57865797
CalculateReissuanceToken(token, issuance_details.entropy, blind_issuances);
57875798

@@ -5791,6 +5802,7 @@ UniValue issueasset(const JSONRPCRequest& request)
57915802
ret.pushKV("entropy", issuance_details.entropy.GetHex());
57925803
ret.pushKV("asset", asset.GetHex());
Has conversations. Original line has conversations.
57935804
ret.pushKV("token", token.GetHex());
5805+
ret.pushKV("contract_hash", issuance_details.contract_hash.GetHex());
57945806
return ret;
57955807
}
57965808

‎src/wallet/wallet.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3223,7 +3223,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
32233223
CAsset token;
32243224
//TODO take optional contract hash
32253225
// Initial issuance always uses vin[0]
3226-
GenerateAssetEntropy(entropy, txNew.vin[0].prevout, uint256());
3226+
GenerateAssetEntropy(entropy, txNew.vin[0].prevout, issuance_details->contract_hash);
32273227
CalculateAsset(asset, entropy);
32283228
CalculateReissuanceToken(token, entropy, issuance_details->blind_issuance);
32293229
CScript blindingScript(CScript() << OP_RETURN << std::vector<unsigned char>(txNew.vin[0].prevout.hash.begin(), txNew.vin[0].prevout.hash.end()) << txNew.vin[0].prevout.n);
Has a conversation. Original line has a conversation.

‎src/wallet/wallet.h

+1
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,7 @@ struct CoinSelectionParams
629629

630630
struct IssuanceDetails {
631631
bool issuing = false;
632+
uint256 contract_hash;
632633

633634
bool blind_issuance = true;
634635
CAsset reissuance_asset;

0 commit comments

Comments
 (0)
Please sign in to comment.