mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
I really like this PR, but it wound up being pretty nontrivial to merge. The crux is that it pulls PSBT signing logic into scriptpubkey manager, which is where it belongs, but for us this means reasoning about pegins inside script/sign.cpp. However, sign.cpp is part of libbitcoin_common, which does not include anything for reasoning about PoW or RPC (lol) or anything heavy about that. This means that some pegin validation had to remain split between the wallet/rpc layer and sign.cpp. I added a new file script/pegins.cpp which has the (one) method we actually need in sign.cpp. Aside from that, this diff is very large but is mostly just moving our code changes to wallet/psbtwallet.* into wallet/wallet.* where those functions now live. As far as review, it's probably not worthwhile to spend too much too much time on this since it's going to be change again in #16528 and others. The test coverage is pretty extensive.
23 lines
758 B
C++
23 lines
758 B
C++
// Copyright (c) 2020-2020 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
// ELEMENTS
|
|
|
|
#include <primitives/transaction.h>
|
|
#include <script/pegins.h>
|
|
#include <script/script.h>
|
|
#include <streams.h>
|
|
#include <version.h>
|
|
|
|
CTxOut GetPeginOutputFromWitness(const CScriptWitness& pegin_witness) {
|
|
if (pegin_witness.stack.size() < 4) {
|
|
return CTxOut();
|
|
}
|
|
|
|
CDataStream stream(pegin_witness.stack[0], SER_NETWORK, PROTOCOL_VERSION);
|
|
CAmount value;
|
|
stream >> value;
|
|
|
|
return CTxOut(CAsset(pegin_witness.stack[1]), CConfidentialValue(value), CScript(pegin_witness.stack[3].begin(), pegin_witness.stack[3].end()));
|
|
}
|