| 36 | } |
| 37 | |
| 38 | bool PartiallySignedTransaction::Merge(const PartiallySignedTransaction& psbt) |
| 39 | { |
| 40 | // Prohibited to merge two PSBTs over different transactions |
| 41 | if (GetUniqueID() != psbt.GetUniqueID()) { |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | assert(*tx_version == psbt.tx_version); |
| 46 | for (unsigned int i = 0; i < inputs.size(); ++i) { |
| 47 | if (!inputs[i].Merge(psbt.inputs[i])) { |
| 48 | return false; |
| 49 | } |
| 50 | } |
| 51 | for (unsigned int i = 0; i < outputs.size(); ++i) { |
| 52 | if (!outputs[i].Merge(psbt.outputs[i])) { |
| 53 | return false; |
| 54 | } |
| 55 | } |
| 56 | for (auto& xpub_pair : psbt.m_xpubs) { |
| 57 | if (m_xpubs.count(xpub_pair.first) == 0) { |
| 58 | m_xpubs[xpub_pair.first] = xpub_pair.second; |
| 59 | } else { |
| 60 | m_xpubs[xpub_pair.first].insert(xpub_pair.second.begin(), xpub_pair.second.end()); |
| 61 | } |
| 62 | } |
| 63 | for (auto& scalar : psbt.m_scalar_offsets) { |
| 64 | m_scalar_offsets.insert(scalar); |
| 65 | } |
| 66 | if (fallback_locktime == std::nullopt && psbt.fallback_locktime != std::nullopt) fallback_locktime = psbt.fallback_locktime; |
| 67 | if (m_tx_modifiable == std::nullopt && psbt.m_tx_modifiable != std::nullopt) m_tx_modifiable = psbt.m_tx_modifiable; |
| 68 | unknown.insert(psbt.unknown.begin(), psbt.unknown.end()); |
| 69 | |
| 70 | return true; |
| 71 | } |
| 72 | |
| 73 | bool PartiallySignedTransaction::ComputeTimeLock(uint32_t& locktime) const |
| 74 | { |
no test coverage detected