MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / PSBTInput

Class PSBTInput

src/script/sign.h:204–426  ·  view source on GitHub ↗

A structure for PSBTs which contain per-input information */

Source from the content-addressed store, hash-verified

202
203/** A structure for PSBTs which contain per-input information */
204struct PSBTInput
205{
206 CTransactionRef non_witness_utxo;
207 CTxOut witness_utxo;
208 CScript redeem_script;
209 CScript witness_script;
210 CScript final_script_sig;
211 CScriptWitness final_script_witness;
212 std::map<CPubKey, std::vector<uint32_t>> hd_keypaths;
213 std::map<CKeyID, SigPair> partial_sigs;
214 std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown;
215 int sighash_type = 0;
216
217 bool IsNull() const;
218 void FillSignatureData(SignatureData& sigdata) const;
219 void FromSignatureData(const SignatureData& sigdata);
220 void Merge(const PSBTInput& input);
221 bool IsSane() const;
222 PSBTInput() {}
223
224 template <typename Stream>
225 inline void Serialize(Stream& s) const {
226 // Write the utxo
227 // If there is a non-witness utxo, then don't add the witness one.
228 if (non_witness_utxo) {
229 SerializeToVector(s, PSBT_IN_NON_WITNESS_UTXO);
230 OverrideStream<Stream> os(&s, s.GetType(), s.GetVersion() | SERIALIZE_TRANSACTION_NO_WITNESS);
231 SerializeToVector(os, non_witness_utxo);
232 } else if (!witness_utxo.IsNull()) {
233 SerializeToVector(s, PSBT_IN_WITNESS_UTXO);
234 SerializeToVector(s, witness_utxo);
235 }
236
237 if (final_script_sig.empty() && final_script_witness.IsNull()) {
238 // Write any partial signatures
239 for (auto sig_pair : partial_sigs) {
240 SerializeToVector(s, PSBT_IN_PARTIAL_SIG, MakeSpan(sig_pair.second.first));
241 s << sig_pair.second.second;
242 }
243
244 // Write the sighash type
245 if (sighash_type > 0) {
246 SerializeToVector(s, PSBT_IN_SIGHASH);
247 SerializeToVector(s, sighash_type);
248 }
249
250 // Write the redeem script
251 if (!redeem_script.empty()) {
252 SerializeToVector(s, PSBT_IN_REDEEMSCRIPT);
253 s << redeem_script;
254 }
255
256 // Write the witness script
257 if (!witness_script.empty()) {
258 SerializeToVector(s, PSBT_IN_WITNESSSCRIPT);
259 s << witness_script;
260 }
261

Callers 2

createpsbtFunction · 0.85
converttopsbtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected