Merge #587: CreateTransaction should still print blinded tx info during fundraw etc

dc1ede8f2 CreateTransaction should still print blinded tx info during fundraw etc (Gregory Sanders)

Pull request description:

  This should result in better diagnosing of `fundrawtransaction` behavior in case of bugs with blinding.

Tree-SHA512: 4bbd3d58f24dbb0d21fe150154c55eeb617734a2edb6211ff743448d744367e089ee8196aa06ec6fb9fb38e45ca5e1bb4c490dcb9fdda75a288fbec2112b1078
This commit is contained in:
Steven Roose 2019-04-22 10:03:37 +01:00
commit 346c54401a
No known key found for this signature in database
GPG key ID: 7FC91380BB4CE800

View file

@ -3498,6 +3498,37 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
}
}
// Print blinded transaction info before we possibly blow it away when !sign.
if (blind_details) {
std::string summary = "CreateTransaction created blinded transaction:\nIN: ";
for (unsigned int i = 0; i < selected_coins.size(); ++i) {
if (i > 0) {
summary += " ";
}
summary += strprintf("#%d: %s [%s] (%s [%s])\n", i,
selected_coins[i].value,
selected_coins[i].txout.nValue.IsExplicit() ? "explicit" : "blinded",
selected_coins[i].asset.GetHex(),
selected_coins[i].txout.nAsset.IsExplicit() ? "explicit" : "blinded"
);
}
summary += "OUT: ";
for (unsigned int i = 0; i < txNew.vout.size(); ++i) {
if (i > 0) {
summary += " ";
}
CTxOut unblinded = blind_details->tx_unblinded_unsigned.vout[i];
summary += strprintf("#%d: %s%s [%s] (%s [%s])\n", i,
txNew.vout[i].IsFee() ? "[fee] " : "",
unblinded.nValue.GetAmount(),
txNew.vout[i].nValue.IsExplicit() ? "explicit" : "blinded",
unblinded.nAsset.GetAsset().GetHex(),
txNew.vout[i].nAsset.IsExplicit() ? "explicit" : "blinded"
);
}
WalletLogPrintf(summary+"\n");
}
if (sign)
{
int nIn = 0;
@ -3536,37 +3567,6 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac
strFailReason = _("Transaction too large");
return false;
}
// Print unblinded transaction overview.
if (blind_details) {
std::string summary = "CreateTransaction created blinded transaction:\nIN: ";
for (unsigned int i = 0; i < selected_coins.size(); ++i) {
if (i > 0) {
summary += " ";
}
summary += strprintf("#%d: %s [%s] (%s [%s])\n", i,
selected_coins[i].value,
selected_coins[i].txout.nValue.IsExplicit() ? "explicit" : "blinded",
selected_coins[i].asset.GetHex(),
selected_coins[i].txout.nAsset.IsExplicit() ? "explicit" : "blinded"
);
}
summary += "OUT: ";
for (unsigned int i = 0; i < tx->vout.size(); ++i) {
if (i > 0) {
summary += " ";
}
CTxOut unblinded = blind_details->tx_unblinded_unsigned.vout[i];
summary += strprintf("#%d: %s%s [%s] (%s [%s])\n", i,
tx->vout[i].IsFee() ? "[fee] " : "",
unblinded.nValue.GetAmount(),
tx->vout[i].nValue.IsExplicit() ? "explicit" : "blinded",
unblinded.nAsset.GetAsset().GetHex(),
tx->vout[i].nAsset.IsExplicit() ? "explicit" : "blinded"
);
}
WalletLogPrintf(summary+"\n");
}
}
if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {