Skip to content

Commit 9d80e71

Browse files
authored
Merge pull request #60 from buffrr/fix-sends
Tx builder include send requests
2 parents f59f98f + ce6fdef commit 9d80e71

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

wallet/src/builder.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,16 @@ impl Iterator for BuilderIterator<'_> {
568568
);
569569
}
570570
}
571+
if !params.sends.is_empty() {
572+
// TODO: resolved address recipient
573+
for send in &params.sends {
574+
detailed_tx.add_send(
575+
send.amount,
576+
None,
577+
send.recipient.script_pubkey(),
578+
);
579+
}
580+
}
571581
Some(Ok(detailed_tx))
572582
}
573583
StackOp::Open(params) => {
@@ -789,14 +799,15 @@ impl Builder {
789799
}
790800
if !opens.is_empty()
791801
|| !transfers.is_empty()
802+
|| !sends.is_empty()
792803
|| !executes.is_empty()
793804
|| auction_outputs.is_some()
794805
{
795806
stack.push(StackOp::Prepare(CreateParams {
796807
opens,
797808
executes,
798809
transfers,
799-
sends: vec![],
810+
sends,
800811
bidouts: auction_outputs,
801812
}));
802813
}

wallet/src/tx_event.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct BidoutEventDetails {
5151
pub struct SendEventDetails {
5252
#[serde(skip_serializing_if = "Option::is_none")]
5353
pub to_space: Option<String>,
54-
pub resolved_address: ScriptBuf,
54+
pub script_pubkey: ScriptBuf,
5555
pub amount: Amount,
5656
}
5757

@@ -344,7 +344,7 @@ impl TxRecord {
344344
details: Some(
345345
serde_json::to_value(SendEventDetails {
346346
to_space,
347-
resolved_address,
347+
script_pubkey: resolved_address,
348348
amount,
349349
})
350350
.expect("json value"),
@@ -526,6 +526,7 @@ impl FromStr for TxEventKind {
526526
"send" => Ok(TxEventKind::Send),
527527
"script" => Ok(TxEventKind::Script),
528528
"fee-bump" => Ok(TxEventKind::FeeBump),
529+
"buy" => Ok(TxEventKind::Buy),
529530
_ => Err("invalid event kind"),
530531
}
531532
}

0 commit comments

Comments
 (0)