MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / ComputeTimeLock

Method ComputeTimeLock

src/psbt.cpp:88–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86}
87
88std::optional<uint32_t> PartiallySignedTransaction::ComputeTimeLock() const
89{
90 if (GetVersion() >= 2) {
91 std::optional<uint32_t> time_lock{0};
92 std::optional<uint32_t> height_lock{0};
93 for (const PSBTInput& input : inputs) {
94 if (input.time_locktime.has_value() && !input.height_locktime.has_value()) {
95 height_lock.reset(); // Transaction can no longer have a height locktime
96 if (!time_lock.has_value()) {
97 return std::nullopt;
98 }
99 } else if (!input.time_locktime.has_value() && input.height_locktime.has_value()) {
100 time_lock.reset(); // Transaction can no longer have a time locktime
101 if (!height_lock.has_value()) {
102 return std::nullopt;
103 }
104 }
105 if (input.time_locktime && time_lock.has_value()) {
106 time_lock = std::max(time_lock, input.time_locktime);
107 }
108 if (input.height_locktime && height_lock.has_value()) {
109 height_lock = std::max(height_lock, input.height_locktime);
110 }
111 }
112 if (height_lock.has_value() && *height_lock > 0) {
113 return *height_lock;
114 }
115 if (time_lock.has_value() && *time_lock > 0) {
116 return *time_lock;
117 }
118 }
119 return fallback_locktime.value_or(0);
120}
121
122std::optional<CMutableTransaction> PartiallySignedTransaction::GetUnsignedTx() const
123{

Callers 1

CheckTimeLockFunction · 0.80

Calls 3

has_valueMethod · 0.45
resetMethod · 0.45
value_orMethod · 0.45

Tested by 1

CheckTimeLockFunction · 0.64