diff --git a/Cargo.toml b/Cargo.toml index 5b4897f..249e41a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "ord-rs" categories = ["cryptography::cryptocurrencies"] license = "MIT" -version = "0.1.7" +version = "0.2.0" authors = ["Finity Technologies"] description = "A library for working with Ordinal inscriptions." repository = "https://github.com/bitfinity-network/ord-rs" diff --git a/examples/edict.rs b/examples/edict.rs index 6ae5be1..7f7e000 100644 --- a/examples/edict.rs +++ b/examples/edict.rs @@ -72,12 +72,11 @@ async fn main() -> anyhow::Result<()> { let destination = Address::from_str(&args.destination)?.assume_checked(); let unsigned_tx = builder.create_edict_transaction(&CreateEdictTxArgs { - rune: args.rune_id, + runes: vec![(args.rune_id, amount)], inputs: inputs.clone(), destination, change_address: sender_address.clone(), rune_change_address: sender_address, - amount, fee_rate: FeeRate::from_sat_per_vb(10).unwrap(), })?; diff --git a/src/wallet/builder/rune.rs b/src/wallet/builder/rune.rs index 927e80e..ee85fb3 100644 --- a/src/wallet/builder/rune.rs +++ b/src/wallet/builder/rune.rs @@ -41,8 +41,8 @@ impl From for OrdRunestone { /// Arguments for the [`OrdTransactionBuilder::create_edict_transaction`] method. pub struct CreateEdictTxArgs { - /// Identifier of the rune to be transferred. - pub rune: RuneId, + /// Identifier and amount of the runes to be transferred. + pub runes: Vec<(RuneId, u128)>, /// Inputs that contain rune and funding BTC balances. pub inputs: Vec, /// Address of the recipient of the rune transfer. @@ -51,8 +51,6 @@ pub struct CreateEdictTxArgs { pub change_address: Address, /// Address that will receive leftovers of runes. pub rune_change_address: Address, - /// Amount of the rune to be transferred. - pub amount: u128, /// Current BTC fee rate. pub fee_rate: FeeRate, } @@ -90,12 +88,18 @@ impl OrdTransactionBuilder { /// * Returns [`OrdError::InsufficientBalance`] if the inputs BTC amount is not enough /// to cover the outputs and transaction fee. pub fn create_edict_transaction(&self, args: &CreateEdictTxArgs) -> OrdResult { - let runestone = OrdRunestone { - edicts: vec![Edict { - id: args.rune, - amount: args.amount, + let edicts = args + .runes + .iter() + .map(|(rune, amount)| Edict { + id: *rune, + amount: *amount, output: 2, - }], + }) + .collect(); + + let runestone = OrdRunestone { + edicts, etching: None, mint: None, pointer: None, @@ -263,7 +267,7 @@ mod tests { let builder = OrdTransactionBuilder::new(public_key, ScriptType::P2WSH, wallet); let args = CreateEdictTxArgs { - rune: RuneId::new(219, 1).unwrap(), + runes: vec![(RuneId::new(219, 1).unwrap(), 9500)], inputs: vec![ TxInputInfo { outpoint: OutPoint::new( @@ -332,7 +336,6 @@ mod tests { ) .unwrap() .assume_checked(), - amount: 9500, fee_rate: FeeRate::from_sat_per_vb(10).unwrap(), }; let unsigned_tx = builder