| 833 | } |
| 834 | |
| 835 | void PartiallySignedTransaction::SetupFromTx(const CMutableTransaction& tx) |
| 836 | { |
| 837 | tx_version = tx.nVersion; |
| 838 | fallback_locktime = tx.nLockTime; |
| 839 | |
| 840 | uint32_t i; |
| 841 | for (i = 0; i < tx.vin.size(); ++i) { |
| 842 | PSBTInput& input = inputs.at(i); |
| 843 | const CTxIn& txin = tx.vin.at(i); |
| 844 | |
| 845 | input.prev_txid = txin.prevout.hash; |
| 846 | input.prev_out = txin.prevout.n; |
| 847 | input.sequence = txin.nSequence; |
| 848 | |
| 849 | // Elements things |
| 850 | if (!txin.assetIssuance.IsNull()) { |
| 851 | if (txin.assetIssuance.nAmount.IsExplicit()) { |
| 852 | input.m_issuance_value = txin.assetIssuance.nAmount.GetAmount(); |
| 853 | } else { |
| 854 | input.m_issuance_value_commitment = txin.assetIssuance.nAmount; |
| 855 | } |
| 856 | |
| 857 | if (txin.assetIssuance.nInflationKeys.IsExplicit()) { |
| 858 | input.m_issuance_inflation_keys_amount = txin.assetIssuance.nInflationKeys.GetAmount(); |
| 859 | } else { |
| 860 | input.m_issuance_inflation_keys_commitment = txin.assetIssuance.nInflationKeys; |
| 861 | } |
| 862 | |
| 863 | if (!txin.assetIssuance.assetBlindingNonce.IsNull()) { |
| 864 | input.m_issuance_blinding_nonce = txin.assetIssuance.assetBlindingNonce; |
| 865 | } |
| 866 | if (!txin.assetIssuance.assetEntropy.IsNull()) { |
| 867 | input.m_issuance_asset_entropy = txin.assetIssuance.assetEntropy; |
| 868 | } |
| 869 | } |
| 870 | // Peg-in things |
| 871 | if (txin.m_is_pegin) { |
| 872 | CAmount peg_in_value; |
| 873 | CAsset asset; |
| 874 | if (DecomposePeginWitness(tx.witness.vtxinwit[i].m_pegin_witness, peg_in_value, asset, input.m_peg_in_genesis_hash, input.m_peg_in_claim_script, input.m_peg_in_tx, input.m_peg_in_txout_proof)) { |
| 875 | input.m_peg_in_value = peg_in_value; |
| 876 | assert(asset == Params().GetConsensus().pegged_asset); |
| 877 | } |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | for (i = 0; i < tx.vout.size(); ++i) { |
| 882 | PSBTOutput& output = outputs.at(i); |
| 883 | const CTxOut& txout = tx.vout.at(i); |
| 884 | |
| 885 | output.script = txout.scriptPubKey; |
| 886 | |
| 887 | // Elements things |
| 888 | if (txout.nAsset.IsExplicit()) { |
| 889 | output.m_asset = txout.nAsset.GetAsset().id; |
| 890 | } else { |
| 891 | output.m_asset_commitment = txout.nAsset; |
| 892 | } |
nothing calls this directly
no test coverage detected