|
13 | 13 | #include "utilstrencodings.h"
|
14 | 14 | #include "validationinterface.h"
|
15 | 15 | #include "script/ismine.h"
|
| 16 | +#include "script/sign.h" |
16 | 17 | #include "wallet/crypter.h"
|
17 | 18 | #include "wallet/walletdb.h"
|
18 | 19 | #include "wallet/rpcwallet.h"
|
@@ -796,6 +797,8 @@ class CWallet : public CCryptoKeyStore, public CValidationInterface
|
796 | 797 | void ListAccountCreditDebit(const std::string& strAccount, std::list<CAccountingEntry>& entries);
|
797 | 798 | bool AddAccountingEntry(const CAccountingEntry&);
|
798 | 799 | bool AddAccountingEntry(const CAccountingEntry&, CWalletDB *pwalletdb);
|
| 800 | + template <typename ContainerType> |
| 801 | + bool DummySignTx(CMutableTransaction &txNew, const ContainerType &coins); |
799 | 802 |
|
800 | 803 | static CFeeRate minTxFee;
|
801 | 804 | static CFeeRate fallbackFee;
|
@@ -1028,4 +1031,28 @@ class CAccount
|
1028 | 1031 | }
|
1029 | 1032 | };
|
1030 | 1033 |
|
| 1034 | +// Helper for producing a bunch of max-sized low-S signatures (eg 72 bytes) |
| 1035 | +// ContainerType is meant to hold pair<CWalletTx *, int>, and be iterable |
| 1036 | +// so that each entry corresponds to each vIn, in order. |
| 1037 | +template <typename ContainerType> |
| 1038 | +bool CWallet::DummySignTx(CMutableTransaction &txNew, const ContainerType &coins) |
| 1039 | +{ |
| 1040 | + // Fill in dummy signatures for fee calculation. |
| 1041 | + int nIn = 0; |
| 1042 | + for (const auto& coin : coins) |
| 1043 | + { |
| 1044 | + const CScript& scriptPubKey = coin.first->tx->vout[coin.second].scriptPubKey; |
| 1045 | + SignatureData sigdata; |
| 1046 | + |
| 1047 | + if (!ProduceSignature(DummySignatureCreator(this), scriptPubKey, sigdata)) |
| 1048 | + { |
| 1049 | + return false; |
| 1050 | + } else { |
| 1051 | + UpdateTransaction(txNew, nIn, sigdata); |
| 1052 | + } |
| 1053 | + |
| 1054 | + nIn++; |
| 1055 | + } |
| 1056 | + return true; |
| 1057 | +} |
1031 | 1058 | #endif // BITCOIN_WALLET_WALLET_H
|
0 commit comments