forked from ordinals/ord
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ordinals:master' into master
- Loading branch information
Showing
19 changed files
with
492 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use super::*; | ||
|
||
#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] | ||
pub struct PendingOutput { | ||
pub commit: Txid, | ||
pub rune: SpacedRune, | ||
} | ||
#[derive(Debug, Parser)] | ||
pub(crate) struct Pending {} | ||
|
||
impl Pending { | ||
pub(crate) fn run(self, wallet: Wallet) -> SubcommandResult { | ||
let etchings = wallet | ||
.pending_etchings()? | ||
.into_iter() | ||
.map(|(_, entry)| { | ||
let spaced_rune = entry.output.rune.unwrap().rune; | ||
|
||
PendingOutput { | ||
rune: spaced_rune, | ||
commit: entry.commit.txid(), | ||
} | ||
}) | ||
.collect::<Vec<PendingOutput>>(); | ||
|
||
Ok(Some(Box::new(etchings) as Box<dyn Output>)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use super::*; | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct RunicUtxo { | ||
pub output: OutPoint, | ||
pub runes: BTreeMap<SpacedRune, Decimal>, | ||
} | ||
|
||
pub(crate) fn run(wallet: Wallet) -> SubcommandResult { | ||
let unspent_outputs = wallet.utxos(); | ||
let runic_utxos = wallet.get_runic_outputs()?; | ||
|
||
let runic_utxos = unspent_outputs | ||
.iter() | ||
.filter_map(|(output, _)| { | ||
if runic_utxos.contains(output) { | ||
let rune_balances = wallet.get_runes_balances_in_output(output).ok()?; | ||
let mut runes = BTreeMap::new(); | ||
|
||
for (spaced_rune, pile) in rune_balances { | ||
runes | ||
.entry(spaced_rune) | ||
.and_modify(|decimal: &mut Decimal| { | ||
assert_eq!(decimal.scale, pile.divisibility); | ||
decimal.value += pile.amount; | ||
}) | ||
.or_insert(Decimal { | ||
value: pile.amount, | ||
scale: pile.divisibility, | ||
}); | ||
} | ||
|
||
Some(RunicUtxo { | ||
output: *output, | ||
runes, | ||
}) | ||
} else { | ||
None | ||
} | ||
}) | ||
.collect::<Vec<RunicUtxo>>(); | ||
|
||
Ok(Some(Box::new(runic_utxos))) | ||
} |
Oops, something went wrong.