Skip to content
Permalink
Browse files

Sign with SIGHASH_FORKID when UAHF is activated.

Summary:
The wallet code will sign transactions in a replay protected manner by default to ensure user funds are safe once the fork activated.

Depends on D312, D310

Test Plan:
Many integration test are testing the signing code of the wallet, they are all still green.
I'd like to run live test on testnet soon, but we need to land that code first.

Reviewers: #bitcoin_abc, freetrader

Reviewed By: #bitcoin_abc, freetrader

Subscribers: freetrader

Differential Revision: https://reviews.bitcoinabc.org/D327
  • Loading branch information...
deadalnix committed Jul 8, 2017
1 parent 2ba4f7c commit fda9dab6a9fba4a95aa2d9620f28b787efccf748
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/wallet/wallet.cpp
@@ -35,6 +35,7 @@
#include <boost/thread.hpp>

CWallet *pwalletMain = nullptr;

/** Transaction fee set by the user */
CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE);
unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET;
@@ -2964,6 +2965,15 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient> &vecSend,
}

if (sign) {
uint32_t nHashType = SIGHASH_ALL;
// If we already forked, use replay protected tx by default.
// It is ok to use GetConfig here, because we'll just use replay
// protected transaction only fairly soon anyway, so we can just
// remove that call.
if (IsUAHFenabledForCurrentBlock(GetConfig())) {
nHashType |= SIGHASH_FORKID;
}

CTransaction txNewConst(txNew);
int nIn = 0;
for (const auto &coin : setCoins) {
@@ -2975,7 +2985,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient> &vecSend,
TransactionSignatureCreator(
this, &txNewConst, nIn,
coin.first->tx->vout[coin.second].nValue,
SIGHASH_ALL),
nHashType),
scriptPubKey, sigdata)) {
strFailReason = _("Signing transaction failed");
return false;

0 comments on commit fda9dab

Please sign in to comment.
You can’t perform that action at this time.