mirror of
https://github.com/jwinterm/grin-wallet.git
synced 2026-11-30 10:53:56 +01:00
Command line implementation of invoice commands (#96)
* add issue_invoice_tx command * rustfmt * add first pass at process_invoice command * start of process_invoice fn * rustfmt * rename issue invoice and process invoice to invoice and pay * add prompting and display information to pay invoice command * rustfmt * support invoice transactions in finalize command * rustfmt
This commit is contained in:
@@ -330,9 +330,6 @@ where
|
||||
batch.commit()?;
|
||||
}
|
||||
|
||||
// Always lock the context for now
|
||||
selection::lock_tx_context(&mut *w, slate, &context)?;
|
||||
tx::update_message(&mut *w, &mut ret_slate)?;
|
||||
Ok(ret_slate)
|
||||
}
|
||||
|
||||
|
||||
+42
-3
@@ -27,14 +27,14 @@ use crate::grin_core::core::verifier_cache::LruVerifierCache;
|
||||
use crate::grin_core::libtx::{aggsig, build, secp_ser, tx_fee};
|
||||
use crate::grin_core::map_vec;
|
||||
use crate::grin_keychain::{BlindSum, BlindingFactor, Keychain};
|
||||
use crate::grin_util::secp;
|
||||
use crate::grin_util::secp::key::{PublicKey, SecretKey};
|
||||
use crate::grin_util::secp::Signature;
|
||||
use crate::grin_util::RwLock;
|
||||
use crate::grin_util::{self, secp, RwLock};
|
||||
use failure::ResultExt;
|
||||
use rand::rngs::mock::StepRng;
|
||||
use rand::thread_rng;
|
||||
use serde_json;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
|
||||
@@ -113,6 +113,36 @@ impl ParticipantMessageData {
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ParticipantMessageData {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln!(f, "")?;
|
||||
write!(f, "Participant ID {} ", self.id)?;
|
||||
if self.id == 0 {
|
||||
writeln!(f, "(Sender)")?;
|
||||
} else {
|
||||
writeln!(f, "(Recipient)")?;
|
||||
}
|
||||
writeln!(f, "---------------------")?;
|
||||
let static_secp = grin_util::static_secp_instance();
|
||||
let static_secp = static_secp.lock();
|
||||
writeln!(
|
||||
f,
|
||||
"Public Key: {}",
|
||||
&grin_util::to_hex(self.public_key.serialize_vec(&static_secp, true).to_vec())
|
||||
)?;
|
||||
let message = match self.message.clone() {
|
||||
None => "None".to_owned(),
|
||||
Some(m) => m,
|
||||
};
|
||||
writeln!(f, "Message: {}", message)?;
|
||||
let message_sig = match self.message_sig.clone() {
|
||||
None => "None".to_owned(),
|
||||
Some(m) => grin_util::to_hex(m.to_raw_data().to_vec()),
|
||||
};
|
||||
writeln!(f, "Message Signature: {}", message_sig)
|
||||
}
|
||||
}
|
||||
|
||||
/// A 'Slate' is passed around to all parties to build up all of the public
|
||||
/// transaction data needed to create a finalized transaction. Callers can pass
|
||||
/// the slate around by whatever means they choose, (but we can provide some
|
||||
@@ -344,7 +374,6 @@ impl Slate {
|
||||
|
||||
/// Creates the final signature, callable by either the sender or recipient
|
||||
/// (after phase 3: sender confirmation)
|
||||
/// TODO: Only callable by receiver at the moment
|
||||
pub fn finalize<K>(&mut self, keychain: &K) -> Result<(), Error>
|
||||
where
|
||||
K: Keychain,
|
||||
@@ -353,6 +382,16 @@ impl Slate {
|
||||
self.finalize_transaction(keychain, &final_sig)
|
||||
}
|
||||
|
||||
/// Return the participant with the given id
|
||||
pub fn participant_with_id(&self, id: usize) -> Option<ParticipantData> {
|
||||
for p in self.participant_data.iter() {
|
||||
if p.id as usize == id {
|
||||
return Some(p.clone());
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
/// Return the sum of public nonces
|
||||
fn pub_nonce_sum(&self, secp: &secp::Secp256k1) -> Result<PublicKey, Error> {
|
||||
let pub_nonces = self
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
//! * TxKernel fields serialized as hex strings instead of arrays:
|
||||
//! commit
|
||||
//! signature
|
||||
//! * version_info field removed
|
||||
//! * version field removed
|
||||
//! * VersionCompatInfo struct created with fields and added to beginning of struct
|
||||
//! version: u16
|
||||
//! orig_verion: u16,
|
||||
|
||||
Reference in New Issue
Block a user