Skip to content

Commit

Permalink
TTL Implementation (mimblewimble#261)
Browse files Browse the repository at this point in the history
* refactor address generation code into libwallet, bool to flag whether to include proof, add sender address in init_send_tx

* rustfmt

* require payment proof addr as part of init_tx

* rustfmt

* store payment proof on sender transaction side

* rustfmt

* change sig to ed25519 sig

* rustfmt

* add message creation and signature

* rustfmt

* add payment proof verification function

* rustfmt

* validate proof on sender side, store proof

* rustfmt

* fix json tests

* fixes and updates to tests

* added API functions for converting and retrieving proof addresses

* rustfmt

* add payment proof to init_send_tx example

* rustfmt

* incorrect comment

* add commands for requesting payment proofs

* rustfmt

* wire up payment proofs into command line

* rustfmt

* add address command

* rustfmt

* added tor sending from owner api

* rustfmt

* add TTL to slate, transaction log

* ttl cutoff tests

* add ttl check to recieve functions, add tests, modify doctests

* rustfmt

* fixes from upstream changes and test fixes

* rustfmt

* remove unnecessary block header version check
  • Loading branch information
yeastplume authored Dec 2, 2019
1 parent 885af66 commit 0943042
Show file tree
Hide file tree
Showing 25 changed files with 653 additions and 327 deletions.
603 changes: 326 additions & 277 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions api/src/foreign_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ pub trait ForeignRpc {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down Expand Up @@ -253,7 +253,7 @@ pub trait ForeignRpc {
"fee": "7000000",
"height": "5",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"participant_data": [
{
Expand Down Expand Up @@ -283,7 +283,7 @@ pub trait ForeignRpc {
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down Expand Up @@ -420,7 +420,7 @@ pub trait ForeignRpc {
"fee": "7000000",
"height": "5",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"participant_data": [
{
Expand Down Expand Up @@ -455,7 +455,7 @@ pub trait ForeignRpc {
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down
3 changes: 2 additions & 1 deletion api/src/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ use crate::libwallet::{
NodeHeightResult, OutputCommitMapping, Slate, TxLogEntry, WalletInfo, WalletInst,
WalletLCProvider,
};
use crate::util::logger::LoggingConfig;
use crate::util::secp::key::SecretKey;
use crate::util::{from_hex, static_secp_instance, LoggingConfig, Mutex, ZeroingString};
use crate::util::{from_hex, static_secp_instance, Mutex, ZeroingString};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Sender};
use std::sync::Arc;
Expand Down
20 changes: 12 additions & 8 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ pub trait OwnerRpc: Sync + Send {
"num_outputs": 1,
"parent_key_id": "0200000000000000000000000000000000",
"stored_tx": null,
"ttl_cutoff_height": null,
"tx_slate_id": null,
"payment_proof": null,
"tx_type": "ConfirmedCoinbase"
Expand All @@ -258,6 +259,7 @@ pub trait OwnerRpc: Sync + Send {
"num_outputs": 1,
"parent_key_id": "0200000000000000000000000000000000",
"stored_tx": null,
"ttl_cutoff_height": null,
"tx_slate_id": null,
"payment_proof": null,
"tx_type": "ConfirmedCoinbase"
Expand Down Expand Up @@ -343,6 +345,7 @@ pub trait OwnerRpc: Sync + Send {
"message": "my message",
"target_slate_version": null,
"payment_proof_recipient_address": null,
"ttl_blocks": null,
"send_args": null
}
},
Expand All @@ -361,7 +364,7 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down Expand Up @@ -448,7 +451,7 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down Expand Up @@ -514,7 +517,7 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down Expand Up @@ -565,6 +568,7 @@ pub trait OwnerRpc: Sync + Send {
"message": "Ok, here are your grins",
"target_slate_version": null,
"payment_proof_recipient_address": null,
"ttl_blocks": null,
"send_args": null
}
],
Expand All @@ -583,7 +587,7 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down Expand Up @@ -671,7 +675,7 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down Expand Up @@ -760,7 +764,7 @@ pub trait OwnerRpc: Sync + Send {
},
"num_participants": 2,
"id": "0436430c-2b02-624c-2032-570501212b00",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"tx": {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000",
Expand Down Expand Up @@ -835,7 +839,7 @@ pub trait OwnerRpc: Sync + Send {
"fee": "7000000",
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"lock_height": "0",
"num_participants": 2,
Expand Down Expand Up @@ -1116,7 +1120,7 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"payment_proof": null,
"num_participants": 2,
"participant_data": [
Expand Down
23 changes: 14 additions & 9 deletions api/src/owner_rpc_s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ use crate::libwallet::{
OutputCommitMapping, Slate, SlateVersion, StatusMessage, TxLogEntry, VersionedSlate,
WalletInfo, WalletLCProvider,
};
use crate::util::logger::LoggingConfig;
use crate::util::secp::key::{PublicKey, SecretKey};
use crate::util::{static_secp_instance, LoggingConfig, ZeroingString};
use crate::util::{static_secp_instance, ZeroingString};
use crate::{ECDHPubkey, Owner, PubAddress, Token};
use easy_jsonrpc_mw;
use rand::thread_rng;
Expand Down Expand Up @@ -263,6 +264,7 @@ pub trait OwnerRpcS {
"num_outputs": 1,
"parent_key_id": "0200000000000000000000000000000000",
"stored_tx": null,
"ttl_cutoff_height": null,
"tx_slate_id": null,
"payment_proof": null,
"tx_type": "ConfirmedCoinbase"
Expand All @@ -282,6 +284,7 @@ pub trait OwnerRpcS {
"num_outputs": 1,
"parent_key_id": "0200000000000000000000000000000000",
"stored_tx": null,
"ttl_cutoff_height": null,
"payment_proof": null,
"tx_slate_id": null,
"tx_type": "ConfirmedCoinbase"
Expand Down Expand Up @@ -374,6 +377,7 @@ pub trait OwnerRpcS {
"message": "my message",
"target_slate_version": null,
"payment_proof_recipient_address": "d03c09e9c19bb74aa9ea44e0fe5ae237a9bf40bddf0941064a80913a4459c8bb",
"ttl_blocks": null,
"send_args": null
}
},
Expand All @@ -392,7 +396,7 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"num_participants": 2,
"payment_proof": {
"receiver_address": "d03c09e9c19bb74aa9ea44e0fe5ae237a9bf40bddf0941064a80913a4459c8bb",
Expand Down Expand Up @@ -484,7 +488,7 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"num_participants": 2,
"payment_proof": null,
"participant_data": [
Expand Down Expand Up @@ -555,7 +559,7 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"num_participants": 2,
"payment_proof": null,
"participant_data": [
Expand Down Expand Up @@ -606,6 +610,7 @@ pub trait OwnerRpcS {
"message": "Ok, here are your grins",
"target_slate_version": null,
"payment_proof_recipient_address": null,
"ttl_blocks": null,
"send_args": null
}
},
Expand All @@ -624,7 +629,7 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"num_participants": 2,
"payment_proof": null,
"participant_data": [
Expand Down Expand Up @@ -715,7 +720,7 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"num_participants": 2,
"payment_proof": null,
"participant_data": [
Expand Down Expand Up @@ -847,7 +852,7 @@ pub trait OwnerRpcS {
"fee": "7000000",
"height": "5",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"participant_data": [
{
"id": "0",
Expand Down Expand Up @@ -882,7 +887,7 @@ pub trait OwnerRpcS {
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"num_participants": 2,
"payment_proof": null,
"participant_data": [
Expand Down Expand Up @@ -1180,7 +1185,7 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"ttl_cutoff_height": null,
"num_participants": 2,
"participant_data": [
{
Expand Down
2 changes: 1 addition & 1 deletion config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::comments::insert_comments;
use crate::core::global;
use crate::types::{ConfigError, GlobalWalletConfig, GlobalWalletConfigMembers};
use crate::types::{TorConfig, WalletConfig};
use crate::util::LoggingConfig;
use crate::util::logger::LoggingConfig;

/// Wallet configuration file name
pub const WALLET_CONFIG_FILE_NAME: &'static str = "grin-wallet.toml";
Expand Down
2 changes: 1 addition & 1 deletion config/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::io;
use std::path::PathBuf;

use crate::core::global::ChainTypes;
use crate::util::LoggingConfig;
use crate::util::logger::LoggingConfig;

/// Command-line wallet configuration
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
Expand Down
6 changes: 3 additions & 3 deletions controller/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ fn check_middleware(
// allow coinbases to be built regardless
ForeignCheckMiddlewareFn::BuildCoinbase => Ok(()),
_ => {
let mut bhv = 1;
let mut bhv = 2;
if let Some(n) = node_version_info {
bhv = n.block_header_version;
}
if let Some(s) = slate {
if s.version_info.version < CURRENT_SLATE_VERSION
|| (bhv == 1 && s.version_info.block_header_version != 1)
|| (bhv > 1 && s.version_info.block_header_version < GRIN_BLOCK_HEADER_VERSION)
// || (bhv == 3 && s.version_info.block_header_version != 3)
|| (bhv > 3 && s.version_info.block_header_version < GRIN_BLOCK_HEADER_VERSION)
{
Err(ErrorKind::Compatibility(
"Incoming Slate is not compatible with this wallet. \
Expand Down
6 changes: 6 additions & 0 deletions controller/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ pub fn txs(
bMG->"Type",
bMG->"Shared Transaction Id",
bMG->"Creation Time",
bMG->"TTL Cutoff Height",
bMG->"Confirmed?",
bMG->"Confirmation Time",
bMG->"Num. \nInputs",
Expand All @@ -173,6 +174,10 @@ pub fn txs(
};
let entry_type = format!("{}", t.tx_type);
let creation_ts = format!("{}", t.creation_ts.format("%Y-%m-%d %H:%M:%S"));
let ttl_cutoff_height = match t.ttl_cutoff_height {
Some(b) => format!("{}", b),
None => "None".to_owned(),
};
let confirmation_ts = match t.confirmation_ts {
Some(m) => format!("{}", m.format("%Y-%m-%d %H:%M:%S")),
None => "None".to_owned(),
Expand Down Expand Up @@ -212,6 +217,7 @@ pub fn txs(
bFC->entry_type,
bFC->slate_id,
bFB->creation_ts,
bFB->ttl_cutoff_height,
bFC->confirmed,
bFB->confirmation_ts,
bFC->num_inputs,
Expand Down
Loading

0 comments on commit 0943042

Please sign in to comment.