|
@@ -3,7 +3,7 @@ use std::sync::Arc;
|
|
|
|
|
|
use bitcoin::bip32::{DerivationPath, Xpriv};
|
|
|
use bitcoin::secp256k1::{self, Secp256k1};
|
|
|
-use cashu::PublicKey;
|
|
|
+use cashu::{Amount, PublicKey};
|
|
|
use cdk_common::dhke::{sign_message, verify_message};
|
|
|
use cdk_common::mint::MintKeySetInfo;
|
|
|
use cdk_common::nuts::{BlindSignature, BlindedMessage, CurrencyUnit, Id, MintKeySet, Proof};
|
|
@@ -40,7 +40,7 @@ impl DbSignatory {
|
|
|
Arc<dyn database::MintAuthDatabase<Err = database::Error> + Send + Sync>,
|
|
|
>,
|
|
|
seed: &[u8],
|
|
|
- supported_units: HashMap<CurrencyUnit, (u64, u8)>,
|
|
|
+ supported_units: HashMap<CurrencyUnit, (u64, Vec<Amount>)>,
|
|
|
custom_paths: HashMap<CurrencyUnit, DerivationPath>,
|
|
|
) -> Result<Self, Error> {
|
|
|
let secp_ctx = Secp256k1::new();
|
|
@@ -69,7 +69,7 @@ impl DbSignatory {
|
|
|
derivation_path,
|
|
|
Some(0),
|
|
|
CurrencyUnit::Auth,
|
|
|
- 1,
|
|
|
+ &[1.into()],
|
|
|
0,
|
|
|
);
|
|
|
|
|
@@ -80,7 +80,7 @@ impl DbSignatory {
|
|
|
}
|
|
|
|
|
|
// Create new keysets for supported units that aren't covered by the current keysets
|
|
|
- for (unit, (fee, max_order)) in supported_units {
|
|
|
+ for (unit, (fee, amounts)) in supported_units {
|
|
|
if !active_keyset_units.contains(&unit) {
|
|
|
let derivation_path = match custom_paths.get(&unit) {
|
|
|
Some(path) => path.clone(),
|
|
@@ -95,7 +95,7 @@ impl DbSignatory {
|
|
|
derivation_path,
|
|
|
Some(0),
|
|
|
unit.clone(),
|
|
|
- max_order,
|
|
|
+ &amounts,
|
|
|
fee,
|
|
|
);
|
|
|
|
|
@@ -299,48 +299,6 @@ mod test {
|
|
|
use super::*;
|
|
|
|
|
|
#[test]
|
|
|
- fn mint_mod_generate_keyset_from_seed() {
|
|
|
- let seed = "test_seed".as_bytes();
|
|
|
- let keyset = MintKeySet::generate_from_seed(
|
|
|
- &Secp256k1::new(),
|
|
|
- seed,
|
|
|
- 2,
|
|
|
- CurrencyUnit::Sat,
|
|
|
- derivation_path_from_unit(CurrencyUnit::Sat, 0).unwrap(),
|
|
|
- );
|
|
|
-
|
|
|
- assert_eq!(keyset.unit, CurrencyUnit::Sat);
|
|
|
- assert_eq!(keyset.keys.len(), 2);
|
|
|
-
|
|
|
- let expected_amounts_and_pubkeys: HashSet<(Amount, PublicKey)> = vec![
|
|
|
- (
|
|
|
- Amount::from(1),
|
|
|
- PublicKey::from_hex(
|
|
|
- "0257aed43bf2c1cdbe3e7ae2db2b27a723c6746fc7415e09748f6847916c09176e",
|
|
|
- )
|
|
|
- .unwrap(),
|
|
|
- ),
|
|
|
- (
|
|
|
- Amount::from(2),
|
|
|
- PublicKey::from_hex(
|
|
|
- "03ad95811e51adb6231613f9b54ba2ba31e4442c9db9d69f8df42c2b26fbfed26e",
|
|
|
- )
|
|
|
- .unwrap(),
|
|
|
- ),
|
|
|
- ]
|
|
|
- .into_iter()
|
|
|
- .collect();
|
|
|
-
|
|
|
- let amounts_and_pubkeys: HashSet<(Amount, PublicKey)> = keyset
|
|
|
- .keys
|
|
|
- .iter()
|
|
|
- .map(|(amount, pair)| (*amount, pair.public_key))
|
|
|
- .collect();
|
|
|
-
|
|
|
- assert_eq!(amounts_and_pubkeys, expected_amounts_and_pubkeys);
|
|
|
- }
|
|
|
-
|
|
|
- #[test]
|
|
|
fn mint_mod_generate_keyset_from_xpriv() {
|
|
|
let seed = "test_seed".as_bytes();
|
|
|
let network = Network::Bitcoin;
|
|
@@ -348,7 +306,7 @@ mod test {
|
|
|
let keyset = MintKeySet::generate_from_xpriv(
|
|
|
&Secp256k1::new(),
|
|
|
xpriv,
|
|
|
- 2,
|
|
|
+ &vec![1.into(), 2.into()],
|
|
|
CurrencyUnit::Sat,
|
|
|
derivation_path_from_unit(CurrencyUnit::Sat, 0).unwrap(),
|
|
|
);
|