v31.1-roots.1 · Commit 6: [PATCH 06/17] feat(wallet): preserve Roots signing and spend controls on v31
src/interfaces/wallet.h
Before: src/interfaces/wallet.h · After: src/interfaces/wallet.h
File metadata
index bba9e058cc017ea72026751ddba7fca56e56bf0d..9a73dfae206fdc315e21e433d5f74dcad420e150 100644
Download original patch · Release notes
Diff rows 1–123 of 123. Line numbers refer to the original before/after files.
+ Added− RemovedUnmarked lines are context.
Scroll the code area horizontally to read long lines. The two line-number columns refer to before and after.
src/interfaces/wallet.h
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#include <common/signmessage.h>
|
|
10
10
|
#include <consensus/amount.h>
|
|
11
11
|
#include <interfaces/chain.h>
|
|
12
|
+
#include <policy/feerate.h>
|
|
12
13
|
#include <primitives/transaction_identifier.h>
|
|
13
14
|
#include <pubkey.h>
|
|
14
15
|
#include <script/script.h>
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
#include <util/result.h>
|
|
18
19
|
#include <util/ui_change_type.h>
|
|
19
20
|
|
|
21
|
+
#include <atomic>
|
|
20
22
|
#include <cstdint>
|
|
21
23
|
#include <functional>
|
|
22
24
|
#include <map>
|
|
@@ -27,7 +29,6 @@
|
|
|
27
29
|
#include <utility>
|
|
28
30
|
#include <vector>
|
|
29
31
|
|
|
30
|
-
class CFeeRate;
|
|
31
32
|
class CKey;
|
|
32
33
|
enum class FeeReason;
|
|
33
34
|
enum class OutputType;
|
|
@@ -58,6 +59,42 @@ struct WalletTxOut;
|
|
|
58
59
|
struct WalletTxStatus;
|
|
59
60
|
struct WalletMigrationResult;
|
|
60
61
|
|
|
62
|
+
//! Shared authorization for an asynchronous sweep. Cancellation and the final
|
|
63
|
+
//! transition into broadcast are mutually exclusive, so a successful cancel
|
|
64
|
+
//! guarantees that broadcast cannot start afterwards.
|
|
65
|
+
class SweepAuthorization
|
|
66
|
+
{
|
|
67
|
+
public:
|
|
68
|
+
bool Cancel()
|
|
69
|
+
{
|
|
70
|
+
State expected{State::ACTIVE};
|
|
71
|
+
if (m_state.compare_exchange_strong(expected, State::CANCELLED)) return true;
|
|
72
|
+
return expected == State::CANCELLED;
|
|
73
|
+
}
|
|
74
|
+
bool IsCancelled() const { return m_state.load() == State::CANCELLED; }
|
|
75
|
+
bool BeginBroadcast()
|
|
76
|
+
{
|
|
77
|
+
State expected{State::ACTIVE};
|
|
78
|
+
return m_state.compare_exchange_strong(expected, State::BROADCAST_STARTED);
|
|
79
|
+
}
|
|
80
|
+
bool BroadcastStarted() const { return m_state.load() == State::BROADCAST_STARTED; }
|
|
81
|
+
|
|
82
|
+
private:
|
|
83
|
+
enum class State : uint8_t { ACTIVE, CANCELLED, BROADCAST_STARTED };
|
|
84
|
+
std::atomic<State> m_state{State::ACTIVE};
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
//! Result of a transient-private-key sweep. The supplied key is never retained
|
|
88
|
+
//! by this interface or by the wallet.
|
|
89
|
+
struct WalletSweepResult {
|
|
90
|
+
CTransactionRef tx;
|
|
91
|
+
CAmount amount{0};
|
|
92
|
+
CAmount fee{0};
|
|
93
|
+
size_t inputs{0};
|
|
94
|
+
int64_t vsize{0};
|
|
95
|
+
bool broadcast{false};
|
|
96
|
+
};
|
|
97
|
+
|
|
61
98
|
using WalletOrderForm = std::vector<std::pair<std::string, std::string>>;
|
|
62
99
|
using WalletValueMap = std::map<std::string, std::string>;
|
|
63
100
|
|
|
@@ -107,6 +144,13 @@ public:
|
|
|
107
144
|
//! Return whether wallet has private key.
|
|
108
145
|
virtual bool isSpendable(const CTxDestination& dest) = 0;
|
|
109
146
|
|
|
147
|
+
//! Sweep one transient private key to a destination controlled by this wallet.
|
|
148
|
+
virtual util::Result<WalletSweepResult> sweepPrivateKey(const SecureString& private_key,
|
|
149
|
+
const CTxDestination& destination,
|
|
150
|
+
bool broadcast,
|
|
151
|
+
const std::optional<Txid>& expected_txid,
|
|
152
|
+
const std::shared_ptr<SweepAuthorization>& authorization) = 0;
|
|
153
|
+
|
|
110
154
|
//! Add or update address.
|
|
111
155
|
virtual bool setAddressBook(const CTxDestination& dest, const std::string& name, const std::optional<wallet::AddressPurpose>& purpose) = 0;
|
|
112
156
|
|
|
@@ -239,7 +283,8 @@ public:
|
|
|
239
283
|
virtual CoinsList listCoins() = 0;
|
|
240
284
|
|
|
241
285
|
//! Return wallet transaction output information.
|
|
242
|
-
virtual std::vector<WalletTxOut> getCoins(const std::vector<COutPoint>& outputs) = 0;
|
|
286
|
+
virtual std::vector<WalletTxOut> getCoins(const std::vector<COutPoint>& outputs,
|
|
287
|
+
const std::optional<CFeeRate>& feerate = std::nullopt) = 0;
|
|
243
288
|
|
|
244
289
|
//! Get required fee.
|
|
245
290
|
virtual CAmount getRequiredFee(unsigned int tx_bytes) = 0;
|
|
@@ -253,6 +298,9 @@ public:
|
|
|
253
298
|
//! Get tx confirm target.
|
|
254
299
|
virtual unsigned int getConfirmTarget() = 0;
|
|
255
300
|
|
|
301
|
+
//! Return whether new transactions signal replace-by-fee by default.
|
|
302
|
+
virtual bool getDefaultRbf() = 0;
|
|
303
|
+
|
|
256
304
|
// Return whether HD enabled.
|
|
257
305
|
virtual bool hdEnabled() = 0;
|
|
258
306
|
|
|
@@ -413,10 +461,29 @@ struct WalletTxStatus
|
|
|
413
461
|
//! Wallet transaction output.
|
|
414
462
|
struct WalletTxOut
|
|
415
463
|
{
|
|
464
|
+
//! Outpoint identifying this output in the wallet.
|
|
465
|
+
COutPoint outpoint;
|
|
416
466
|
CTxOut txout;
|
|
467
|
+
//! Wallet's smart transaction time for this output.
|
|
417
468
|
int64_t time;
|
|
418
469
|
int depth_in_main_chain = -1;
|
|
419
470
|
bool is_spent = false;
|
|
471
|
+
//! Wallet-owned facts used to present coin-control choices.
|
|
472
|
+
int input_bytes = -1;
|
|
473
|
+
std::optional<CAmount> effective_value;
|
|
474
|
+
CAmount ancestor_bump_fees{0};
|
|
475
|
+
//! Native wallet ownership/selection status; does not guarantee complete signing.
|
|
476
|
+
bool is_spendable = false;
|
|
477
|
+
bool is_watch_only = false;
|
|
478
|
+
bool is_solvable = false;
|
|
479
|
+
bool is_safe = false;
|
|
480
|
+
bool is_locked = false;
|
|
481
|
+
bool is_reused = false;
|
|
482
|
+
bool is_immature = false;
|
|
483
|
+
bool is_change = false;
|
|
484
|
+
CTxDestination address;
|
|
485
|
+
CTxDestination grouping_address;
|
|
486
|
+
std::string label;
|
|
420
487
|
};
|
|
421
488
|
|
|
422
489
|
//! Migrated wallet info
|