Repository: ordinals/ord (rust)

Issue:
`wallet cardinals` should not return runic utxos
As of right now `ord wallet cardinals` returns runic utxos.

This is an unexpected behaviour, as spending those utxos results in spent rune balances.

`wallet cardinals` should return only common non-rune, non-inscription utxos

Pull request description:
Do not show runic outputs in cardinals command
Fixes #3648

Patch:
diff --git a/src/subcommand/wallet/cardinals.rs b/src/subcommand/wallet/cardinals.rs
index 1da96c4b..6b7413c7 100644
--- a/src/subcommand/wallet/cardinals.rs
+++ b/src/subcommand/wallet/cardinals.rs
@@ -15,10 +15,12 @@ pub(crate) fn run(wallet: Wallet) -> SubcommandResult {
     .map(|satpoint| satpoint.outpoint)
     .collect::<BTreeSet<OutPoint>>();
 
+  let runic_utxos = wallet.get_runic_outputs()?;
+
   let cardinal_utxos = unspent_outputs
     .iter()
     .filter_map(|(output, txout)| {
-      if inscribed_utxos.contains(output) {
+      if inscribed_utxos.contains(output) || runic_utxos.contains(output) {
         None
       } else {
         Some(CardinalUtxo {


Test patch:
diff --git a/tests/wallet/cardinals.rs b/tests/wallet/cardinals.rs
index 31daae0b..360e1d1c 100644
--- a/tests/wallet/cardinals.rs
+++ b/tests/wallet/cardinals.rs
@@ -25,3 +25,50 @@ fn cardinals() {
 
   assert_eq!(all_outputs.len() - cardinal_outputs.len(), 1);
 }
+
+#[test]
+fn cardinals_does_not_show_runic_outputs() {
+  let core = mockcore::builder().network(Network::Regtest).build();
+
+  let ord = TestServer::spawn_with_server_args(&core, &["--regtest", "--index-runes"], &[]);
+
+  create_wallet(&core, &ord);
+
+  core.mine_blocks(1);
+
+  batch(
+    &core,
+    &ord,
+    batch::File {
+      etching: Some(batch::Etching {
+        supply: "1000".parse().unwrap(),
+        divisibility: 0,
+        terms: None,
+        premine: "1000".parse().unwrap(),
+        rune: SpacedRune {
+          rune: Rune(RUNE),
+          spacers: 0,
+        },
+        symbol: '¢',
+        turbo: false,
+      }),
+      inscriptions: vec![batch::Entry {
+        file: Some("inscription.jpeg".into()),
+        ..default()
+      }],
+      ..default()
+    },
+  );
+
+  let all_outputs = CommandBuilder::new("--regtest wallet outputs")
+    .core(&core)
+    .ord(&ord)
+    .run_and_deserialize_output::<Vec<Output>>();
+
+  let cardinal_outputs = CommandBuilder::new("--regtest wallet cardinals")
+    .core(&core)
+    .ord(&ord)
+    .run_and_deserialize_output::<Vec<CardinalUtxo>>();
+
+  assert_eq!(all_outputs.len() - cardinal_outputs.len(), 2);
+}