HF2 Slate Changes (#258)

* Update slate version to V3, define PaymentInfoV3 and add needed serialization

* rustfmt

* add ttl and payment proof info to slate

* rustfmt

* add documentation for updated fields

* doc test fixes
This commit is contained in:
Yeastplume
2019-11-20 11:01:38 +00:00
committed by GitHub
parent e74c0e2571
commit 9c2177e3d9
13 changed files with 470 additions and 200 deletions
+12 -2
View File
@@ -53,7 +53,7 @@ pub trait ForeignRpc {
"Ok": {
"foreign_api_version": 2,
"supported_slate_versions": [
"V2"
"V3"
]
}
}
@@ -133,6 +133,8 @@ pub trait ForeignRpc {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -251,6 +253,8 @@ pub trait ForeignRpc {
"fee": "7000000",
"height": "5",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"participant_data": [
{
"id": "0",
@@ -279,6 +283,8 @@ pub trait ForeignRpc {
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -414,6 +420,8 @@ pub trait ForeignRpc {
"fee": "7000000",
"height": "5",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"participant_data": [
{
"id": "1",
@@ -447,6 +455,8 @@ pub trait ForeignRpc {
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -529,7 +539,7 @@ where
fn build_coinbase(&self, block_fees: &BlockFees) -> Result<VersionedCoinbase, ErrorKind> {
let cb: CbData = Foreign::build_coinbase(self, block_fees).map_err(|e| e.kind())?;
Ok(VersionedCoinbase::into_version(cb, SlateVersion::V2))
Ok(VersionedCoinbase::into_version(cb, SlateVersion::V3))
}
fn verify_slate_messages(&self, slate: VersionedSlate) -> Result<(), ErrorKind> {
+42 -26
View File
@@ -17,7 +17,7 @@ use uuid::Uuid;
use crate::core::core::Transaction;
use crate::keychain::{Identifier, Keychain};
use crate::libwallet::slate_versions::v2::TransactionV2;
use crate::libwallet::slate_versions::v3::TransactionV3;
use crate::libwallet::{
AcctPathMapping, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient, NodeHeightResult,
OutputCommitMapping, Slate, SlateVersion, TxLogEntry, VersionedSlate, WalletInfo,
@@ -358,6 +358,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -397,8 +399,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 1
}
}
@@ -443,6 +445,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -477,8 +481,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 1
}
}
@@ -507,6 +511,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -541,8 +547,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
},
@@ -573,6 +579,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -625,8 +633,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
@@ -659,6 +667,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -698,8 +708,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
},
@@ -740,12 +750,14 @@ pub trait OwnerRpc: Sync + Send {
"params": [
{
"version_info": {
"version": 2,
"orig_version": 2,
"version": 3,
"orig_version": 3,
"block_header_version": 2
},
"num_participants": 2,
"id": "0436430c-2b02-624c-2032-570501212b00",
"ttl_cutoff_height": "0",
"payment_proof": null,
"tx": {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000",
"body": {
@@ -819,6 +831,8 @@ pub trait OwnerRpc: Sync + Send {
"fee": "7000000",
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"ttl_cutoff_height": "0",
"payment_proof": null,
"lock_height": "0",
"num_participants": 2,
"participant_data": [
@@ -876,8 +890,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
@@ -954,7 +968,7 @@ pub trait OwnerRpc: Sync + Send {
```
*/
fn post_tx(&self, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind>;
fn post_tx(&self, tx: TransactionV3, fluff: bool) -> Result<(), ErrorKind>;
/**
Networked version of [Owner::cancel_tx](struct.Owner.html#method.cancel_tx).
@@ -1080,7 +1094,7 @@ pub trait OwnerRpc: Sync + Send {
# , false, 5, true, true, false);
```
*/
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV2>, ErrorKind>;
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV3>, ErrorKind>;
/**
Networked version of [Owner::verify_slate_messages](struct.Owner.html#method.verify_slate_messages).
@@ -1098,6 +1112,8 @@ pub trait OwnerRpc: Sync + Send {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"payment_proof": null,
"num_participants": 2,
"participant_data": [
{
@@ -1137,8 +1153,8 @@ pub trait OwnerRpc: Sync + Send {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
@@ -1271,13 +1287,13 @@ where
fn init_send_tx(&self, args: InitTxArgs) -> Result<VersionedSlate, ErrorKind> {
let slate = Owner::init_send_tx(self, None, args).map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(slate, version))
}
fn issue_invoice_tx(&self, args: IssueInvoiceTxArgs) -> Result<VersionedSlate, ErrorKind> {
let slate = Owner::issue_invoice_tx(self, None, args).map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(slate, version))
}
@@ -1288,14 +1304,14 @@ where
) -> Result<VersionedSlate, ErrorKind> {
let out_slate = Owner::process_invoice_tx(self, None, &Slate::from(in_slate), args)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(out_slate, version))
}
fn finalize_tx(&self, in_slate: VersionedSlate) -> Result<VersionedSlate, ErrorKind> {
let out_slate =
Owner::finalize_tx(self, None, &Slate::from(in_slate)).map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(out_slate, version))
}
@@ -1312,13 +1328,13 @@ where
Owner::cancel_tx(self, None, tx_id, tx_slate_id).map_err(|e| e.kind())
}
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV2>, ErrorKind> {
fn get_stored_tx(&self, tx: &TxLogEntry) -> Result<Option<TransactionV3>, ErrorKind> {
Owner::get_stored_tx(self, None, tx)
.map(|x| x.map(|y| TransactionV2::from(y)))
.map(|x| x.map(|y| TransactionV3::from(y)))
.map_err(|e| e.kind())
}
fn post_tx(&self, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind> {
fn post_tx(&self, tx: TransactionV3, fluff: bool) -> Result<(), ErrorKind> {
Owner::post_tx(self, None, &Transaction::from(tx), fluff).map_err(|e| e.kind())
}
+43 -27
View File
@@ -19,7 +19,7 @@ use crate::config::{TorConfig, WalletConfig};
use crate::core::core::Transaction;
use crate::core::global;
use crate::keychain::{Identifier, Keychain};
use crate::libwallet::slate_versions::v2::TransactionV2;
use crate::libwallet::slate_versions::v3::TransactionV3;
use crate::libwallet::{
AcctPathMapping, ErrorKind, InitTxArgs, IssueInvoiceTxArgs, NodeClient, NodeHeightResult,
OutputCommitMapping, Slate, SlateVersion, StatusMessage, TxLogEntry, VersionedSlate,
@@ -389,7 +389,9 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"num_participants": 2,
"payment_proof": null,
"participant_data": [
{
"id": "0",
@@ -428,8 +430,8 @@ pub trait OwnerRpcS {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 1
}
}
@@ -475,7 +477,9 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"num_participants": 2,
"payment_proof": null,
"participant_data": [
{
"id": "1",
@@ -509,8 +513,8 @@ pub trait OwnerRpcS {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 1
}
}
@@ -544,7 +548,9 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"num_participants": 2,
"payment_proof": null,
"participant_data": [
{
"id": "1",
@@ -578,8 +584,8 @@ pub trait OwnerRpcS {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
},
@@ -610,7 +616,9 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"num_participants": 2,
"payment_proof": null,
"participant_data": [
{
"id": "1",
@@ -662,8 +670,8 @@ pub trait OwnerRpcS {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
@@ -699,7 +707,9 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"num_participants": 2,
"payment_proof": null,
"participant_data": [
{
"id": "0",
@@ -738,8 +748,8 @@ pub trait OwnerRpcS {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
},
@@ -782,12 +792,13 @@ pub trait OwnerRpcS {
"token": "d202964900000000d302964900000000d402964900000000d502964900000000",
"slate": {
"version_info": {
"version": 2,
"orig_version": 2,
"version": 3,
"orig_version": 3,
"block_header_version": 2
},
"num_participants": 2,
"id": "0436430c-2b02-624c-2032-570501212b00",
"payment_proof": null,
"tx": {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000",
"body": {
@@ -828,6 +839,7 @@ pub trait OwnerRpcS {
"fee": "7000000",
"height": "5",
"lock_height": "0",
"ttl_cutoff_height": "0",
"participant_data": [
{
"id": "0",
@@ -862,7 +874,9 @@ pub trait OwnerRpcS {
"height": "5",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "0",
"ttl_cutoff_height": "0",
"num_participants": 2,
"payment_proof": null,
"participant_data": [
{
"id": "0",
@@ -918,8 +932,8 @@ pub trait OwnerRpcS {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
@@ -998,7 +1012,7 @@ pub trait OwnerRpcS {
```
*/
fn post_tx(&self, token: Token, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind>;
fn post_tx(&self, token: Token, tx: TransactionV3, fluff: bool) -> Result<(), ErrorKind>;
/**
Networked version of [Owner::cancel_tx](struct.Owner.html#method.cancel_tx).
@@ -1138,7 +1152,7 @@ pub trait OwnerRpcS {
&self,
token: Token,
tx: &TxLogEntry,
) -> Result<Option<TransactionV2>, ErrorKind>;
) -> Result<Option<TransactionV3>, ErrorKind>;
/**
Networked version of [Owner::verify_slate_messages](struct.Owner.html#method.verify_slate_messages).
@@ -1158,6 +1172,7 @@ pub trait OwnerRpcS {
"height": "4",
"id": "0436430c-2b02-624c-2032-570501212b00",
"lock_height": "4",
"ttl_cutoff_height": "0",
"num_participants": 2,
"participant_data": [
{
@@ -1194,11 +1209,12 @@ pub trait OwnerRpcS {
}
]
},
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000",
"payment_proof": null
},
"version_info": {
"orig_version": 2,
"version": 2,
"orig_version": 3,
"version": 3,
"block_header_version": 2
}
}
@@ -1834,7 +1850,7 @@ where
fn init_send_tx(&self, token: Token, args: InitTxArgs) -> Result<VersionedSlate, ErrorKind> {
let slate = Owner::init_send_tx(self, (&token.keychain_mask).as_ref(), args)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(slate, version))
}
@@ -1845,7 +1861,7 @@ where
) -> Result<VersionedSlate, ErrorKind> {
let slate = Owner::issue_invoice_tx(self, (&token.keychain_mask).as_ref(), args)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(slate, version))
}
@@ -1862,7 +1878,7 @@ where
args,
)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(out_slate, version))
}
@@ -1877,7 +1893,7 @@ where
&Slate::from(in_slate),
)
.map_err(|e| e.kind())?;
let version = SlateVersion::V2;
let version = SlateVersion::V3;
Ok(VersionedSlate::into_version(out_slate, version))
}
@@ -1910,13 +1926,13 @@ where
&self,
token: Token,
tx: &TxLogEntry,
) -> Result<Option<TransactionV2>, ErrorKind> {
) -> Result<Option<TransactionV3>, ErrorKind> {
Owner::get_stored_tx(self, (&token.keychain_mask).as_ref(), tx)
.map(|x| x.map(|y| TransactionV2::from(y)))
.map(|x| x.map(|y| TransactionV3::from(y)))
.map_err(|e| e.kind())
}
fn post_tx(&self, token: Token, tx: TransactionV2, fluff: bool) -> Result<(), ErrorKind> {
fn post_tx(&self, token: Token, tx: TransactionV3, fluff: bool) -> Result<(), ErrorKind> {
Owner::post_tx(
self,
(&token.keychain_mask).as_ref(),