diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 1f6353cd..b8d1196d 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -601,7 +601,7 @@ where let recipients = params.recipients.iter().map(|(r, v)| (r, *v)); for (index, (script_pubkey, value)) in recipients.enumerate() { - if value.is_dust() { + if value.is_dust() && !script_pubkey.is_provably_unspendable() { return Err(Error::OutputBelowDustLimit(index)); } diff --git a/src/wallet/tx_builder.rs b/src/wallet/tx_builder.rs index a0ed93cb..0c7f7f85 100644 --- a/src/wallet/tx_builder.rs +++ b/src/wallet/tx_builder.rs @@ -560,6 +560,13 @@ impl<'a, B, D: BatchDatabase, Cs: CoinSelectionAlgorithm> TxBuilder<'a, B, D, self } + /// Add data as an output, using OP_RETURN + pub fn add_data(&mut self, data: &[u8]) -> &mut Self { + let script = Script::new_op_return(data); + self.add_recipient(script, 0u64); + self + } + /// Sets the address to *drain* excess coins to. /// /// Usually, when there are excess coins they are sent to a change address generated by the