Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced offset creation #407

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
217 changes: 142 additions & 75 deletions Cargo.lock

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions api/src/foreign_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ pub trait ForeignRpc {
"sta": "S1",
"amt": "60000000000",
"fee": "7000000",
"off": "0gKWSQAAAADTApZJAAAAANQClkkAAAAA1QKWSQAAAAA=",
"sigs": [
{
"xs": "AzrCFY+gB38IfeYMGdjkMXU7qltjtuFHfwWipucZDUWS",
"xs": "AwFS0tcuLbp8YIatSaIZ2f8N/g/Zk9yuoi4FjCEAM86T",
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP"
}
]
Expand All @@ -161,11 +162,12 @@ pub trait ForeignRpc {
}
],
"id": "0436430c-2b02-624c-2032-570501212b00",
"off": "pAUskgAAAAGmBSySAAAAAu1WT6tQt1/F6jLOBS/Jvr8=",
"sigs": [
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBsrNb0o39ImngZw4M+ScL1t8tA/vWRSPuSuYiOWBVuW/A==",
"xs": "A4/gRDJD2rFzwGjvX6iRskLSteuJDqCUdebjgRcEQu4W"
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBsFiJtL7+KpZhceAUs9zF+T6CiXy18Hr2cIYcJ9XmH+ag==",
"xs": "A6ZTwAjgK+rW7OC8F/8UHcRBH5NW+xZBLlx7x6fcv3PU"
}
],
"sta": "S2",
Expand Down Expand Up @@ -203,11 +205,12 @@ pub trait ForeignRpc {
"id": "0436430c-2b02-624c-2032-570501212b00",
"sta": "I2",
"fee": "7000000",
"off": "dQ2/T9Q7f0z9aNJpilIvP/bmoArZiVsz8exGSTuDe0k=",
"sigs": [
{
"xs": "Ap8S+fjFSJoYkE3nzUbcM4S3k2nUy8F810spnajCz3RF",
"xs": "AwFS0tcuLbp8YIatSaIZ2f8N/g/Zk9yuoi4FjCEAM86T",
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBsYQNae1fM7ybQkQikD1dHT6bkUFDvL47ftMtjxX8zM4w=="
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBva2TTaoX235HfE7tkK/tQNEReJbfjE9YYbYwmpSYeAdA=="
}
],
"coms": [
Expand Down Expand Up @@ -254,16 +257,16 @@ pub trait ForeignRpc {
],
"fee": "7000000",
"id": "0436430c-2b02-624c-2032-570501212b00",
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000",
"off": "dQ2/T9Q7f0z9aNJpilIvP/bmoArZiVsz8exGSTuDe0k=",
"sigs": [
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBsYQNae1fM7ybQkQikD1dHT6bkUFDvL47ftMtjxX8zM4w==",
"xs": "Ap8S+fjFSJoYkE3nzUbcM4S3k2nUy8F810spnajCz3RF"
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBva2TTaoX235HfE7tkK/tQNEReJbfjE9YYbYwmpSYeAdA==",
"xs": "AwFS0tcuLbp8YIatSaIZ2f8N/g/Zk9yuoi4FjCEAM86T"
},
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBvJ6iGyWdYeTeF32e+KtHXfqw7HKZAJp/6mEBD5Y/LmwA==",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBs1/f5VJx8q5z119Yxw0e+2mzOEx7xQfVfpnlbed+IIdA==",
"xs": "Azu+KkGeounWgQqNZlUucJ0Xg8pQdZpE269j/HnAFkxM"
}
],
Expand Down
71 changes: 38 additions & 33 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,15 @@ pub trait OwnerRpc {
"amt": "6000000000",
"fee": "8000000",
"id": "0436430c-2b02-624c-2032-570501212b00",
"off": "0gKWSQAAAADTApZJAAAAANQClkkAAAAA1QKWSQAAAAA=",
"proof": {
"raddr": "eD9lKGaXQqmQ4Prwpfyl1bMzDje7uc1cYoaW0Dzk6BA=",
"saddr": "Ms3WOSiFT4smKLHc5GJt3N811Wy3z999ZMylgit41NM="
},
"sigs": [
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"xs": "A0tN8vBVi3PqcqHKXEqyAhfGa74IKQVvynq+doiOk0nu"
"xs": "Ajh4zoRXJ/Ok7HbKPz20s4otBdY2uMNjIQi4V/7WPJbe"
}
],
"sta": "S1",
Expand Down Expand Up @@ -447,6 +448,7 @@ pub trait OwnerRpc {
"Ok": {
"amt": "6000000000",
"id": "0436430c-2b02-624c-2032-570501212b00",
"off": "0gKWSQAAAADTApZJAAAAANQClkkAAAAA1QKWSQAAAAA=",
"sigs": [
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
Expand Down Expand Up @@ -483,6 +485,7 @@ pub trait OwnerRpc {
"slate": {
"amt": "6000000000",
"id": "0436430c-2b02-624c-2032-570501212b00",
"off": "QNjHljmHml/Ot7ogVQDjr3a0M8mBzgN/SLj6NuVh8IM=",
"sigs": [
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
Expand Down Expand Up @@ -527,11 +530,12 @@ pub trait OwnerRpc {
],
"fee": "8000000",
"id": "0436430c-2b02-624c-2032-570501212b00",
"off": "CkRYNMTRYXJonCcMMoSQZz8qlEXOyLnKGeS9dhyGDbk=",
"sigs": [
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBthnUD7am+2BEnvlyeut4LnpbUP2/0tc1tJzMVbR3zTGQ==",
"xs": "AwniLyraqbgfUUFLd1uGrNCW4XeU64FZv8/vJ8qkv1yQ"
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBvxgE9v6OVfVVa72Af++81ysw2Qz3CPjFZEesxjIoJ05g==",
"xs": "Ajh4zoRXJ/Ok7HbKPz20s4otBdY2uMNjIQi4V/7WPJbe"
}
],
"sta": "I2",
Expand Down Expand Up @@ -612,17 +616,18 @@ pub trait OwnerRpc {
"ver": "4:2",
"id": "0436430c-2b02-624c-2032-570501212b00",
"sta": "S2",
"off": "pAUskgAAAAGmBSySAAAAAu1WT6tQt1/F6jLOBS/Jvr8=",
"sigs": [
{
"xs": "Ak+bx4yYTHjW6RbToAdGqjD6EXISTI28DL3ct7SGcZvH",
"xs": "Azu+KkGeounWgQqNZlUucJ0Xg8pQdZpE269j/HnAFkxM",
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBupxt1hhcK4GXmXAPoaaSAflsxt+5yiBaDvfDX7gdV9rA=="
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBs1/f5VJx8q5z119Yxw0e+2mzOEx7xQfVfpnlbed+IIdA=="
}
],
"coms": [
{
"c": "CZtIz7H4CiNH3ImBhEnmjnajxoF6UyqOnvK0pcz0NjhQ",
"p": "KXAc6uJiysd7ebhoyIOikuYebegZK4aO3NEwCwlz2ROWsVas5r1nNAKjA94Q3dil5rfxe6ZVeldKZyvQTMJzqwTtjiyoC6xIM0XA7IQ/UhgUzhMB7JrcOJVqErTZSKzOcSlaT1K83rihyfLWstpdcxJipenAJ275BN+e+NSAAUIM1Z91ovGuXHocfGufFA52E+Uu+eJJ8p+TQLfvuAaZ5GAWQyRhb5j9TN49tSSXyRnpUiL//qy35l3sp+NoqAznE8Gd59pTaXJiKO4zb1vUlFOMEsy//rG5v9X8iQbRxkJFtRbxA/qW2cVpdYN2UsHg+lgD18zxFH2Pkn422nF/eteUcdvhkvX1D4enn8P+Aw26VptjS5LSzzB5k8zlRWM68mOJfNfm6/Tcr7F20HNYvcONA+RaSd+pyMZRfNaNFn/79sO03g4t0hkJy61MRnuE5XAL5HOjmsWcZp18FVxLyrm4Am7qNDHHec0nfkki0rl0Lh9meMvoaew7W370Ey3bbN0Gzyfb6yi+crlJ+ol2EOSOOg14n9Lup1q8l7PcfgDlyLPSTkDG8kESrbcjUriaK+8FmTRTOOnnYgKjxG76Y3CVKyrKQarbrg6jJTGsr82rbdBm12nr9Qz088ClnS1fp5YAoge5QXxiP3atBejMz81AOPlEi8QPEnynwNNy5GB04zT+SfWpVuwAVvTaYB5q+A6xpsSVEFSGnmZbKW2MFPNEyi3F/dXfSjZSU2NloWFa2bQiFlx3v4/mWoNcjgxB4HABTrZu+MUlIE6ZCzo9ZjweQiIbSWiVw3ovDBvwXpEjVAnD/j2JqaedbHhgmrGKRjMRkR9x+je7c7FfzTgUPRQE/SzoEATcf/ic8RFdzAw1zhwb+ZQVhvuVl3DyYYzLcRin"
{
"c": "CZtIz7H4CiNH3ImBhEnmjnajxoF6UyqOnvK0pcz0NjhQ",
"p": "KXAc6uJiysd7ebhoyIOikuYebegZK4aO3NEwCwlz2ROWsVas5r1nNAKjA94Q3dil5rfxe6ZVeldKZyvQTMJzqwTtjiyoC6xIM0XA7IQ/UhgUzhMB7JrcOJVqErTZSKzOcSlaT1K83rihyfLWstpdcxJipenAJ275BN+e+NSAAUIM1Z91ovGuXHocfGufFA52E+Uu+eJJ8p+TQLfvuAaZ5GAWQyRhb5j9TN49tSSXyRnpUiL//qy35l3sp+NoqAznE8Gd59pTaXJiKO4zb1vUlFOMEsy//rG5v9X8iQbRxkJFtRbxA/qW2cVpdYN2UsHg+lgD18zxFH2Pkn422nF/eteUcdvhkvX1D4enn8P+Aw26VptjS5LSzzB5k8zlRWM68mOJfNfm6/Tcr7F20HNYvcONA+RaSd+pyMZRfNaNFn/79sO03g4t0hkJy61MRnuE5XAL5HOjmsWcZp18FVxLyrm4Am7qNDHHec0nfkki0rl0Lh9meMvoaew7W370Ey3bbN0Gzyfb6yi+crlJ+ol2EOSOOg14n9Lup1q8l7PcfgDlyLPSTkDG8kESrbcjUriaK+8FmTRTOOnnYgKjxG76Y3CVKyrKQarbrg6jJTGsr82rbdBm12nr9Qz088ClnS1fp5YAoge5QXxiP3atBejMz81AOPlEi8QPEnynwNNy5GB04zT+SfWpVuwAVvTaYB5q+A6xpsSVEFSGnmZbKW2MFPNEyi3F/dXfSjZSU2NloWFa2bQiFlx3v4/mWoNcjgxB4HABTrZu+MUlIE6ZCzo9ZjweQiIbSWiVw3ovDBvwXpEjVAnD/j2JqaedbHhgmrGKRjMRkR9x+je7c7FfzTgUPRQE/SzoEATcf/ic8RFdzAw1zhwb+ZQVhvuVl3DyYYzLcRin"
}
]
}
Expand Down Expand Up @@ -656,17 +661,17 @@ pub trait OwnerRpc {
],
"fee": "7000000",
"id": "0436430c-2b02-624c-2032-570501212b00",
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000",
"off": "dQ2/T9Q7f0z9aNJpilIvP/bmoArZiVsz8exGSTuDe0k=",
"sigs": [
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBupxt1hhcK4GXmXAPoaaSAflsxt+5yiBaDvfDX7gdV9rA==",
"xs": "Ak+bx4yYTHjW6RbToAdGqjD6EXISTI28DL3ct7SGcZvH"
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBs1/f5VJx8q5z119Yxw0e+2mzOEx7xQfVfpnlbed+IIdA==",
"xs": "Azu+KkGeounWgQqNZlUucJ0Xg8pQdZpE269j/HnAFkxM"
},
{
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBs4ZBrvqQei/BwFGx9zICeU//ttQi4yhRalxrLvQek1+A==",
"xs": "AzrCFY+gB38IfeYMGdjkMXU7qltjtuFHfwWipucZDUWS"
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBva2TTaoX235HfE7tkK/tQNEReJbfjE9YYbYwmpSYeAdA==",
"xs": "AwFS0tcuLbp8YIatSaIZ2f8N/g/Zk9yuoi4FjCEAM86T"
}
],
"sta": "S3",
Expand Down Expand Up @@ -698,20 +703,20 @@ pub trait OwnerRpc {
"id": "0436430c-2b02-624c-2032-570501212b00",
"sta": "S3",
"fee": "7000000",
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000",
"sigs": [
{
"xs": "Ak+bx4yYTHjW6RbToAdGqjD6EXISTI28DL3ct7SGcZvH",
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBupxt1hhcK4GXmXAPoaaSAflsxt+5yiBaDvfDX7gdV9rA=="
},
{
"xs": "AzrCFY+gB38IfeYMGdjkMXU7qltjtuFHfwWipucZDUWS",
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBs4ZBrvqQei/BwFGx9zICeU//ttQi4yhRalxrLvQek1+A=="
}
],
"coms": [
"off": "dQ2/T9Q7f0z9aNJpilIvP/bmoArZiVsz8exGSTuDe0k=",
"sigs": [
{
"xs": "Azu+KkGeounWgQqNZlUucJ0Xg8pQdZpE269j/HnAFkxM",
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBs1/f5VJx8q5z119Yxw0e+2mzOEx7xQfVfpnlbed+IIdA=="
},
{
"xs": "AwFS0tcuLbp8YIatSaIZ2f8N/g/Zk9yuoi4FjCEAM86T",
"nonce": "AxuExVZ7EmRAmV0+1aq6BWXXHhg0YEgZ/5wX9enV3QeP",
"part": "jwfd1en1F5z/GUhgNBge12UFuqrVPl2ZQGQSe1bFhBva2TTaoX235HfE7tkK/tQNEReJbfjE9YYbYwmpSYeAdA=="
}
],
"coms": [
{
"f": 1,
"c": "CH3zIwTF1K6LKvC8MecAAZ1yKRDvh91O7DGXuAsgfjBF"
Expand Down Expand Up @@ -1473,11 +1478,11 @@ pub trait OwnerRpc {
"result": {
"Ok": {
"amount": "60000000000",
"excess": "09bac6083b05a32a9d9b37710c70dd0a1ef9329fde0848558976b6f1b81d80ceed",
"excess": "091f151170bfac881479bfb56c7012c52cd4ce4198ad661586374dd499925922fb",
"recipient_address": "pa7wkkdgs5bkteha7lykl7ff2wztgdrxxo442xdcq2lnaphe5aidd4id",
"recipient_sig": "42b6f2bbcee432185993867d1a338e260454ead536bf728f4dcc8f535508715e92a0695486ba3c9945d8ecb2cf7f703a955780253b12d0048f02d318c8f08702",
"recipient_sig": "b9b1885a3f33297df32e1aa4db23220bd305da8ed92ff6873faf3ab2c116fea25e9d0e34bd4f567f022b88a37400821ffbcaec71c9a8c3a327c4626611886d0d",
"sender_address": "glg5mojiqvhywjriwhooiytn3tptlvlmw7h567lezssyek3y2tjzznad",
"sender_sig": "5e3f5596852e83f6db7152fc51c41b4ed8742eb8045fa85a6965c52d09fcb46ba67d4f86660c9f3dc55ab84faea79d11c3831aa77934f7e90695e63d523f8604"
"sender_sig": "611b92331e395c3d29871ac35b1fce78ec595e28ccbe8cc55452da40775e8e46d35a2e84eaffd986935da3275e34d46a8d777d02dabcf4339704c2a621da9700"
}
}
}
Expand Down Expand Up @@ -1506,11 +1511,11 @@ pub trait OwnerRpc {
"token": "d202964900000000d302964900000000d402964900000000d502964900000000",
"proof": {
"amount": "60000000000",
"excess": "09bac6083b05a32a9d9b37710c70dd0a1ef9329fde0848558976b6f1b81d80ceed",
"excess": "091f151170bfac881479bfb56c7012c52cd4ce4198ad661586374dd499925922fb",
"recipient_address": "pa7wkkdgs5bkteha7lykl7ff2wztgdrxxo442xdcq2lnaphe5aidd4id",
"recipient_sig": "42b6f2bbcee432185993867d1a338e260454ead536bf728f4dcc8f535508715e92a0695486ba3c9945d8ecb2cf7f703a955780253b12d0048f02d318c8f08702",
"recipient_sig": "b9b1885a3f33297df32e1aa4db23220bd305da8ed92ff6873faf3ab2c116fea25e9d0e34bd4f567f022b88a37400821ffbcaec71c9a8c3a327c4626611886d0d",
"sender_address": "glg5mojiqvhywjriwhooiytn3tptlvlmw7h567lezssyek3y2tjzznad",
"sender_sig": "5e3f5596852e83f6db7152fc51c41b4ed8742eb8045fa85a6965c52d09fcb46ba67d4f86660c9f3dc55ab84faea79d11c3831aa77934f7e90695e63d523f8604"
"sender_sig": "611b92331e395c3d29871ac35b1fce78ec595e28ccbe8cc55452da40775e8e46d35a2e84eaffd986935da3275e34d46a8d777d02dabcf4339704c2a621da9700"
}
},
"id": 1
Expand Down
1 change: 1 addition & 0 deletions controller/tests/no_change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ fn no_change_test_impl(test_dir: &'static str) -> Result<(), libwallet::Error> {
slate = client1.send_tx_slate_direct("wallet2", &slate)?;
api.tx_lock_outputs(m, &slate)?;
slate = api.finalize_tx(m, &slate)?;
println!("Posted Slate: {:?}", slate);
println!("Posted TX: {}", slate);
stored_excess = Some(slate.tx.as_ref().unwrap().body.kernels[0].excess);
api.post_tx(m, &slate, false)?;
Expand Down
8 changes: 8 additions & 0 deletions impls/src/adapters/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ pub struct PathToSlate(pub PathBuf);

impl SlatePutter for PathToSlate {
fn put_tx(&self, slate: &Slate, as_bin: bool) -> Result<(), Error> {
// For testing (output raw slate data for reference)
/*{
let mut raw_path = self.0.clone();
raw_path.set_extension("raw");
let mut raw_slate = File::create(&raw_path)?;
raw_slate.write_all(&format!("{:?}", slate).as_bytes())?;
raw_slate.sync_all()?;
}*/
let mut pub_tx = File::create(&self.0)?;
// TODO:
let out_slate = {
Expand Down
9 changes: 2 additions & 7 deletions libwallet/src/api_impl/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use strum::IntoEnumIterator;

use crate::api_impl::owner::check_ttl;
use crate::grin_core::core::transaction::Transaction;
use crate::grin_keychain::{BlindingFactor, Keychain};
use crate::grin_keychain::Keychain;
use crate::grin_util::secp::key::SecretKey;
use crate::internal::{selection, tx, updater};
use crate::slate_versions::SlateVersion;
Expand Down Expand Up @@ -96,6 +96,7 @@ where
}

let height = w.last_confirmed_height()?;
let keychain = w.keychain(keychain_mask)?;

let context = tx::add_output_to_slate(
&mut *w,
Expand All @@ -107,7 +108,6 @@ where
use_test_rng,
)?;

let keychain = w.keychain(keychain_mask)?;
let excess = ret_slate.calc_excess(keychain.secp())?;

if let Some(ref mut p) = ret_slate.payment_proof {
Expand Down Expand Up @@ -162,11 +162,6 @@ where
sl.state = SlateState::Invoice3;
if sl.is_compact() {
sl.amount = 0;
// fill in offset in case of delayed posting
sl.offset = match context.offset {
Some(o) => o,
None => BlindingFactor::zero(),
};
}
Ok(sl)
}
36 changes: 18 additions & 18 deletions libwallet/src/api_impl/owner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::grin_util::Mutex;
use crate::util::OnionV3Address;

use crate::api_impl::owner_updater::StatusMessage;
use crate::grin_keychain::{BlindingFactor, Identifier, Keychain};
use crate::grin_keychain::{Identifier, Keychain};
use crate::internal::{keys, scan, selection, tx, updater};
use crate::slate::{PaymentInfo, Slate, SlateState};
use crate::types::{AcctPathMapping, NodeClient, TxLogEntry, WalletBackend, WalletInfo};
Expand Down Expand Up @@ -382,11 +382,6 @@ where
context.payment_proof_derivation_index = Some(deriv_path);
}

context.offset = Some(slate.tx_or_err()?.offset.clone());

//TODO: Remove after HF3
slate.offset = slate.tx_or_err()?.offset.clone();

// Save the aggsig context in our DB for when we
// recieve the transaction back
{
Expand Down Expand Up @@ -427,7 +422,7 @@ where

let mut slate = tx::new_tx_slate(&mut *w, args.amount, true, 2, use_test_rng, None)?;
let height = w.w2n_client().get_chain_tip()?.0;
let mut context = tx::add_output_to_slate(
let context = tx::add_output_to_slate(
&mut *w,
keychain_mask,
&mut slate,
Expand All @@ -441,11 +436,6 @@ where
slate.version_info.version = v;
};

context.offset = Some(slate.tx_or_err()?.offset.clone());

//TODO: Remove after HF3
slate.offset = slate.tx_or_err()?.offset.clone();

// Save the aggsig context in our DB for when we
// recieve the transaction back
{
Expand Down Expand Up @@ -539,7 +529,6 @@ where
if let Ok(c) = context_res {
context.initial_sec_key = c.initial_sec_key;
context.initial_sec_nonce = c.initial_sec_nonce;
context.offset = c.offset;
context.is_invoice = c.is_invoice;
context.fee = c.fee;
context.amount = c.amount;
Expand All @@ -551,6 +540,13 @@ where
}
}

// adjust offset with inputs, repopulate inputs (initiator needs them for now)
// TODO: Revisit post-HF3
if ret_slate.is_compact() {
tx::sub_inputs_from_offset(&mut *w, keychain_mask, &context, &mut ret_slate)?;
selection::repopulate_tx(&mut *w, keychain_mask, &mut ret_slate, &context, false)?;
}

// Save the aggsig context in our DB for when we
// recieve the transaction back
{
Expand Down Expand Up @@ -617,9 +613,18 @@ where
check_ttl(w, &sl)?;
let context = w.get_private_context(keychain_mask, sl.id.as_bytes())?;
let parent_key_id = w.parent_key_id();

// since we're now actually inserting our inputs, pick an offset and adjust
// our contribution to the excess by offset amount
// TODO: Post HF3, this should allow for inputs to be picked at this stage
// as opposed to locking them prior to this stage, as the excess to this point
// will just be the change output

if sl.is_compact() {
tx::sub_inputs_from_offset(&mut *w, keychain_mask, &context, &mut sl)?;
selection::repopulate_tx(&mut *w, keychain_mask, &mut sl, &context, true)?;
}

tx::complete_tx(&mut *w, keychain_mask, &mut sl, &context)?;
tx::verify_slate_payment_proof(&mut *w, keychain_mask, &parent_key_id, &context, &sl)?;
tx::update_stored_tx(&mut *w, keychain_mask, &context, &sl, false)?;
Expand All @@ -631,11 +636,6 @@ where
sl.state = SlateState::Standard3;
if sl.is_compact() {
sl.amount = 0;
// fill in offset in case of delayed posting
sl.offset = match context.offset {
Some(o) => o,
None => BlindingFactor::zero(),
};
}
Ok(sl)
}
Expand Down
Loading