Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support FIRO Lelantus verbose tx #983 #986

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions mm2src/coins/utxo/utxo_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2435,6 +2435,18 @@ fn firo_verbose_block_deserialize() {
let _block: VerboseBlock = json::from_value(json).unwrap();
}

#[test]
fn firo_lelantus_tx() {
// https://explorer.firo.org/tx/06ed4b75010edcf404a315be70903473f44050c978bc37fbcee90e0b49114ba8
let tx_hash = "06ed4b75010edcf404a315be70903473f44050c978bc37fbcee90e0b49114ba8".into();
let electrum = electrum_client_for_test(&[
"electrumx01.firo.org:50001",
"electrumx02.firo.org:50001",
"electrumx03.firo.org:50001",
]);
let _tx = electrum.get_verbose_transaction(tx_hash).wait().unwrap();
}

#[test]
fn test_generate_tx_doge_fee() {
// A tx below 1kb is always 1 doge fee yes.
Expand Down
3 changes: 3 additions & 0 deletions mm2src/mm2_bitcoin/rpc/src/v1/types/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub enum ScriptType {
CreateSender,
Call,
Create,
LelantusMint,
}

impl From<GlobalScriptType> for ScriptType {
Expand Down Expand Up @@ -57,6 +58,7 @@ impl Serialize for ScriptType {
ScriptType::CreateSender => "create_sender".serialize(serializer),
ScriptType::Call => "call".serialize(serializer),
ScriptType::Create => "create".serialize(serializer),
ScriptType::LelantusMint => "lelantusmint".serialize(serializer),
}
}
}
Expand Down Expand Up @@ -92,6 +94,7 @@ impl<'a> Deserialize<'a> for ScriptType {
"create_sender" => Ok(ScriptType::CreateSender),
"call" => Ok(ScriptType::Call),
"create" => Ok(ScriptType::Create),
"lelantusmint" => Ok(ScriptType::LelantusMint),
_ => Err(E::invalid_value(Unexpected::Str(value), &self)),
}
}
Expand Down
12 changes: 12 additions & 0 deletions mm2src/mm2_bitcoin/rpc/src/v1/types/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ pub enum TransactionInputEnum {
Coinbase(CoinbaseTransactionInput),
/// FIRO specific
Sigma(SigmaInput),
/// FIRO specific
Lelantus(LelantusInput),
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
Expand All @@ -106,6 +108,16 @@ pub struct SigmaInput {
sequence: u32,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct LelantusInput {
#[serde(rename = "scriptSig")]
pub script_sig: TransactionInputScript,
#[serde(rename = "nFees")]
n_fees: f64,
serials: Vec<String>,
sequence: u32,
}

impl TransactionInputEnum {
pub fn is_coinbase(&self) -> bool { matches!(self, TransactionInputEnum::Coinbase(_)) }
}
Expand Down