Skip to content

Commit

Permalink
fix: expose runestone
Browse files Browse the repository at this point in the history
  • Loading branch information
veeso committed Jul 26, 2024
1 parent bab13a7 commit 00d6ae8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ mod builder;
mod parser;

pub use builder::signer::{BtcTxSigner, LocalSigner, Wallet};
#[cfg(feature = "rune")]
pub use builder::CreateEdictTxArgs;
pub use builder::{
CreateCommitTransaction, CreateCommitTransactionArgs, CreateCommitTransactionArgsV2,
OrdTransactionBuilder, RedeemScriptPubkey, RevealTransactionArgs, ScriptType,
SignCommitTransactionArgs, TaprootPayload, TxInputInfo, Utxo,
};
#[cfg(feature = "rune")]
pub use builder::{CreateEdictTxArgs, Runestone};
pub use parser::OrdParser;
28 changes: 3 additions & 25 deletions src/wallet/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use bitcoin::{
Transaction, TxIn, TxOut, Txid, Witness, XOnlyPublicKey,
};
#[cfg(feature = "rune")]
use ordinals::{Edict, Etching, RuneId, Runestone as OrdRunestone};
use ordinals::Runestone as OrdRunestone;
use signer::Wallet;

use self::taproot::generate_keypair;
Expand All @@ -21,7 +21,7 @@ use crate::{OrdError, OrdResult};
#[cfg(feature = "rune")]
mod rune;
#[cfg(feature = "rune")]
pub use rune::CreateEdictTxArgs;
pub use rune::{CreateEdictTxArgs, Runestone};

use crate::wallet::builder::signer::LocalSigner;

Expand Down Expand Up @@ -96,28 +96,6 @@ pub struct RevealTransactionArgs {
pub runestone: Option<Runestone>,
}

#[cfg(feature = "rune")]
/// Runestone wrapper; implemented because FOR SOME REASONS, the `Runestone` of `ordinals` doesn't implement Clone...
#[derive(Debug, Clone)]
pub struct Runestone {
pub edicts: Vec<Edict>,
pub etching: Option<Etching>,
pub mint: Option<RuneId>,
pub pointer: Option<u32>,
}

#[cfg(feature = "rune")]
impl From<Runestone> for OrdRunestone {
fn from(runestone: Runestone) -> Self {
OrdRunestone {
edicts: runestone.edicts,
etching: runestone.etching,
mint: runestone.mint,
pointer: runestone.pointer,
}
}
}

/// Type of the script to use. Both are supported, but P2WSH may not be supported by all the indexers
/// So P2TR is preferred
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
Expand Down Expand Up @@ -809,7 +787,7 @@ mod test {
// <https://mempool.space/testnet/tx/a35802655b63f1c99c1fd3ff8fdf3415f3abb735d647d402c0af5e9a73cbe4c6>
// made by address tb1qzc8dhpkg5e4t6xyn4zmexxljc4nkje59dg3ark

use ordinals::Rune;
use ordinals::{Etching, Rune};
let private_key = PrivateKey::from_wif(WIF).unwrap();
let public_key = private_key.public_key(&Secp256k1::new());
let address = Address::p2wpkh(&public_key, Network::Testnet).unwrap();
Expand Down
26 changes: 24 additions & 2 deletions src/wallet/builder/rune.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use bitcoin::absolute::LockTime;
use bitcoin::transaction::Version;
use bitcoin::{Address, Amount, FeeRate, ScriptBuf, Transaction, TxIn, TxOut};
use ordinals::{Edict, RuneId, Runestone};
use ordinals::{Edict, Etching, RuneId, Runestone as OrdRunestone};

use crate::fees::estimate_transaction_fees;
use crate::wallet::builder::TxInputInfo;
Expand All @@ -13,6 +13,28 @@ use crate::{OrdError, OrdTransactionBuilder};
/// The value is same as in `ord` tool.
pub const RUNE_POSTAGE: Amount = Amount::from_sat(10_000);

#[cfg(feature = "rune")]
/// Runestone wrapper; implemented because FOR SOME REASONS, the `Runestone` of `ordinals` doesn't implement Clone...
#[derive(Debug, Clone)]
pub struct Runestone {
pub edicts: Vec<Edict>,
pub etching: Option<Etching>,
pub mint: Option<RuneId>,
pub pointer: Option<u32>,
}

#[cfg(feature = "rune")]
impl From<Runestone> for OrdRunestone {
fn from(runestone: Runestone) -> Self {
OrdRunestone {
edicts: runestone.edicts,
etching: runestone.etching,
mint: runestone.mint,
pointer: runestone.pointer,
}
}
}

/// Arguments for the [`OrdTransactionBuilder::create_edict_transaction`] method.
pub struct CreateEdictTxArgs {
/// Identifier of the rune to be transferred.
Expand Down Expand Up @@ -54,7 +76,7 @@ impl OrdTransactionBuilder {
&self,
args: &CreateEdictTxArgs,
) -> Result<Transaction, OrdError> {
let runestone = Runestone {
let runestone = OrdRunestone {
edicts: vec![Edict {
id: args.rune,
amount: args.amount,
Expand Down

0 comments on commit 00d6ae8

Please sign in to comment.