TTL Implementation (#261)

* 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
This commit is contained in:
Yeastplume
2019-12-02 13:54:57 +00:00
committed by GitHub
parent 9fd1d49dda
commit 45480392da
25 changed files with 653 additions and 327 deletions
+5 -5
View File
@@ -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": [
@@ -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": [
{
@@ -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": [
@@ -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": [
{
@@ -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": [
+2 -1
View File
@@ -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;
+12 -8
View File
@@ -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"
@@ -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"
@@ -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
}
},
@@ -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": [
@@ -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": [
@@ -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": [
@@ -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
}
],
@@ -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": [
@@ -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": [
@@ -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",
@@ -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,
@@ -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": [
+14 -9
View File
@@ -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;
@@ -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"
@@ -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"
@@ -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
}
},
@@ -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",
@@ -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": [
@@ -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": [
@@ -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
}
},
@@ -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": [
@@ -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": [
@@ -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",
@@ -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": [
@@ -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": [
{