Skip to content

Commit

Permalink
Fix bad_optional_access and segmentation fault in gtests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmidem committed Aug 7, 2023
1 parent 7d2f057 commit c4f51b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/transaction_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,10 @@ TransactionBuilderResult TransactionBuilder::Build()
//

if (change > 0) {
auto asset = orchardBuilder.value().primaryAsset.value();
// FIXME: orchardBuilder is not set in TransactionBuilder::TransactionBuilder as orchardAnchor passed as nullopt
auto asset = orchardBuilder.has_value() && orchardBuilder.value().primaryAsset.has_value()
? orchardBuilder.value().primaryAsset.value()
: Asset::Native();
// Send change to the specified change address. If no change address
// was set, send change to the first Sapling address given as input
// if any; otherwise the first Sprout address given as input.
Expand Down
3 changes: 2 additions & 1 deletion src/wallet/wallet_tx_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,8 @@ AddChangePayment(
CAmount targetAmount)
{
// TODO: This is a hack to get the asset from the first spendable input. We need to implement transaction with multiple assets
auto asset = spendable.orchardNoteMetadata[0].GetAsset();
// TODO: FIXME: Is this a correct fix?
auto asset = spendable.orchardNoteMetadata.empty() ? Asset::Native() : spendable.orchardNoteMetadata[0].GetAsset();

assert(changeAmount > 0);

Expand Down

0 comments on commit c4f51b6

Please sign in to comment.