mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-10-17 07:11:36 +02:00
clean up contracts
This commit is contained in:
@@ -958,17 +958,6 @@ where
|
||||
owner::contract_sign(w, keychain_mask, args, slate)
|
||||
}
|
||||
|
||||
/// Return the participant index in the slate that matches this wallet's context.
|
||||
pub fn get_slate_index_matching_my_context(
|
||||
&self,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
slate: &Slate,
|
||||
) -> Result<usize, Error> {
|
||||
let mut w_lock = self.wallet_inst.lock();
|
||||
let w = w_lock.lc_provider()?.wallet_inst()?;
|
||||
owner::get_slate_index_matching_my_context(w, keychain_mask, slate)
|
||||
}
|
||||
|
||||
/// Revoke a contract by double-spending one of its locked inputs.
|
||||
/// The transaction id must identify an existing contract.
|
||||
///
|
||||
|
||||
@@ -274,7 +274,6 @@ fn contract_accounts_impl(test_dir: &'static str) -> Result<(), libwallet::Error
|
||||
let (_, wallet1_info) = api.retrieve_summary_info(m, true, 1)?;
|
||||
assert_eq!(wallet1_info.last_confirmed_height, 13);
|
||||
let (_, txs) = api.retrieve_txs(m, true, None, None, None)?;
|
||||
println!("{:?}", txs);
|
||||
assert_eq!(txs.len(), 5);
|
||||
Ok(())
|
||||
},
|
||||
|
||||
@@ -105,7 +105,6 @@ fn contract_early_proofs_rsr_test_impl(
|
||||
)?;
|
||||
|
||||
assert_eq!(slate.state, SlateState::Invoice1);
|
||||
println!("I1 State slate: {}", slate);
|
||||
slate = roundtrip_slate(&slate, 5)?;
|
||||
|
||||
wallet::controller::owner_single_use(
|
||||
@@ -123,7 +122,6 @@ fn contract_early_proofs_rsr_test_impl(
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
println!("I2 State slate: {}", slate);
|
||||
|
||||
assert_eq!(slate.state, SlateState::Invoice2);
|
||||
slate = roundtrip_slate(&slate, 5)?;
|
||||
@@ -241,9 +239,6 @@ fn contract_early_proofs_rsr_test_impl(
|
||||
);
|
||||
let early_proof_json = serde_json::to_string(&early_proof).unwrap();
|
||||
|
||||
// Should have all proof fields filled out
|
||||
println!("EARLY PAYMENT PROOF: {}", early_proof_json);
|
||||
|
||||
wallet::controller::foreign_single_use(
|
||||
recv_wallet.clone(),
|
||||
PathBuf::from(test_dir),
|
||||
|
||||
@@ -231,8 +231,6 @@ fn contract_early_proofs_srs_test_impl(test_dir: &'static str) -> Result<(), lib
|
||||
);
|
||||
let early_proof_json = serde_json::to_string(&early_proof).unwrap();
|
||||
|
||||
// Should have all proof fields filled out
|
||||
println!("EARLY PAYMENT PROOF: {}", early_proof_json);
|
||||
{
|
||||
let api = grin_wallet_api::Foreign::new(
|
||||
recv_wallet.clone(),
|
||||
|
||||
@@ -234,11 +234,6 @@ fn contract_rsr_tx_impl(test_dir: &'static str) -> Result<(), libwallet::Error>
|
||||
wallet_info.amount_currently_spendable,
|
||||
4 * 60_000_000_000 + 5_000_000_000 - expected_fees_paid.unwrap().fee() // we expect the balance of 4 mined blocks + 5 Grin - fees paid
|
||||
);
|
||||
// println!("txlogentry: {:#?}", tx_log);
|
||||
// println!("wallet info: {:#?}", wallet_info);
|
||||
// let (validated, commits) = api.retrieve_outputs(m, true, false, Some(tx_log.id))?;
|
||||
// println!("commits: {:#?}", commits);
|
||||
// panic!("lala");
|
||||
Ok(())
|
||||
},
|
||||
)?;
|
||||
|
||||
@@ -51,7 +51,6 @@ fn contract_self_spend_custom_tx_impl(test_dir: &'static str) -> Result<(), libw
|
||||
PathBuf::from(test_dir),
|
||||
|api, m| {
|
||||
let (_, commits) = api.retrieve_outputs(m, true, false, None)?;
|
||||
println!("OOOT: {:?}", commits[0].output);
|
||||
use_inputs = format!(
|
||||
"{},{}",
|
||||
commits[0].output.commit.as_ref().unwrap(),
|
||||
|
||||
@@ -144,9 +144,7 @@ fn contract_srs_mwixnet_tx_impl(test_dir: &'static str) -> Result<(), libwallet:
|
||||
// get last output
|
||||
let last_output = outputs.1[outputs.1.len() - 1].clone();
|
||||
|
||||
let mwixnet_req = api.create_mwixnet_req(m, ¶ms, &last_output.commit, true)?;
|
||||
|
||||
println!("MWIXNET REQ: {:?}", mwixnet_req);
|
||||
api.create_mwixnet_req(m, ¶ms, &last_output.commit, true)?;
|
||||
|
||||
// check output we created comsig for is indeed locked
|
||||
let outputs = api.retrieve_outputs(recv_mask, false, false, None)?;
|
||||
|
||||
@@ -1657,21 +1657,6 @@ where
|
||||
contract::revoke(&mut *w, keychain_mask, &args)
|
||||
}
|
||||
|
||||
/// Return the slate participant index matching this wallet's context
|
||||
pub fn get_slate_index_matching_my_context<C, K>(
|
||||
w: &mut WalletBackend<C, K>,
|
||||
keychain_mask: Option<&SecretKey>,
|
||||
slate: &Slate,
|
||||
) -> Result<usize, Error>
|
||||
where
|
||||
C: NodeClient,
|
||||
K: Keychain,
|
||||
{
|
||||
let keychain = w.keychain(keychain_mask)?;
|
||||
let context = w.get_private_context(keychain_mask, slate.id.as_bytes())?;
|
||||
slate.find_index_matching_context(&keychain, &context)
|
||||
}
|
||||
|
||||
/// Create MXMixnet request
|
||||
pub fn create_mwixnet_req<C, K>(
|
||||
w: &mut WalletBackend<C, K>,
|
||||
|
||||
@@ -50,7 +50,7 @@ pub fn create_tx_log_entry(
|
||||
if net_change > 0 {
|
||||
t.amount_credited = net_change as u64;
|
||||
} else {
|
||||
t.amount_debited = -net_change as u64;
|
||||
t.amount_debited = net_change.unsigned_abs();
|
||||
}
|
||||
t.ttl_cutoff_height = match slate.ttl_cutoff_height {
|
||||
0 => None,
|
||||
@@ -520,6 +520,18 @@ where
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn tx_log_amounts() {
|
||||
let slate = Slate::blank(2, false);
|
||||
for (net_change, credited, debited) in
|
||||
[(1, 1, 0), (0, 0, 0), (-1, 0, 1), (i64::MIN, 0, 1u64 << 63)]
|
||||
{
|
||||
let entry = create_tx_log_entry(&slate, net_change, Identifier::zero(), 0).unwrap();
|
||||
assert_eq!(entry.amount_credited, credited);
|
||||
assert_eq!(entry.amount_debited, debited);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fee_contribution_kernel_split() {
|
||||
let (n_inputs, n_outputs, n_kernels) = (1, 1, 1);
|
||||
|
||||
@@ -64,7 +64,7 @@ impl Readable for SlateStateV4 {
|
||||
}
|
||||
|
||||
/// Allow serializing of Uuids not defined in crate
|
||||
pub struct UuidWrap(pub Uuid);
|
||||
pub(crate) struct UuidWrap(pub Uuid);
|
||||
|
||||
impl Writeable for UuidWrap {
|
||||
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), grin_ser::Error> {
|
||||
@@ -82,7 +82,7 @@ impl Readable for UuidWrap {
|
||||
}
|
||||
|
||||
/// Helper struct to serialize optional fields efficiently
|
||||
pub struct SlateOptFields {
|
||||
pub(crate) struct SlateOptFields {
|
||||
/// num parts, default 2
|
||||
pub num_parts: u8,
|
||||
/// amt, default 0
|
||||
|
||||
Reference in New Issue
Block a user