Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
Breeze
Commits
16d3e3cb
Commit
16d3e3cb
authored
Jun 15, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added some comments
parent
25670725
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
6 deletions
+15
-6
PaymentStateMachine.cs
Breeze/src/Breeze.TumbleBit.Client/PaymentStateMachine.cs
+15
-6
No files found.
Breeze/src/Breeze.TumbleBit.Client/PaymentStateMachine.cs
View file @
16d3e3cb
...
@@ -54,6 +54,8 @@ namespace Breeze.TumbleBit.Client
...
@@ -54,6 +54,8 @@ namespace Breeze.TumbleBit.Client
FeeRate
feeRate
=
null
;
FeeRate
feeRate
=
null
;
switch
(
phase
)
switch
(
phase
)
{
{
// in the registration phase, Bob asks the tumbler for a voucher.
// he cannot open it so he gives it to Alice.
case
CyclePhase
.
Registration
:
case
CyclePhase
.
Registration
:
if
(
session
.
ClientChannelNegotiation
==
null
)
if
(
session
.
ClientChannelNegotiation
==
null
)
{
{
...
@@ -69,6 +71,9 @@ namespace Breeze.TumbleBit.Client
...
@@ -69,6 +71,9 @@ namespace Breeze.TumbleBit.Client
logger
.
LogInformation
(
"Registration Complete"
);
logger
.
LogInformation
(
"Registration Complete"
);
}
}
break
;
break
;
// in this phase, Alice creates 2 transactions: an escrow transaction and a redeem transaction (in case things don't go as planned)
// on the next phase, she sends the blinded voucher to the tumbler, who doesn't know this voucher is coming from Bob.
// the tumbler signs the voucher and replies with a solution to the voucher.
case
CyclePhase
.
ClientChannelEstablishment
:
case
CyclePhase
.
ClientChannelEstablishment
:
if
(
session
.
ClientChannelNegotiation
.
Status
==
TumblerClientSessionStates
.
WaitingTumblerClientTransactionKey
)
if
(
session
.
ClientChannelNegotiation
.
Status
==
TumblerClientSessionStates
.
WaitingTumblerClientTransactionKey
)
{
{
...
@@ -90,15 +95,12 @@ namespace Breeze.TumbleBit.Client
...
@@ -90,15 +95,12 @@ namespace Breeze.TumbleBit.Client
}
}
session
.
SolverClientSession
=
session
.
ClientChannelNegotiation
.
SetClientSignedTransaction
(
clientEscrowTx
);
session
.
SolverClientSession
=
session
.
ClientChannelNegotiation
.
SetClientSignedTransaction
(
clientEscrowTx
);
correlation
=
GetCorrelation
(
session
.
SolverClientSession
.
EscrowedCoin
.
ScriptPubKey
);
correlation
=
GetCorrelation
(
session
.
SolverClientSession
.
EscrowedCoin
.
ScriptPubKey
);
// Tracker.AddressCreated(cycle.Start, TransactionType.ClientEscrow, escrowTxOut.ScriptPubKey, correlation);
// Tracker.AddressCreated(cycle.Start, TransactionType.ClientEscrow, escrowTxOut.ScriptPubKey, correlation);
// Tracker.TransactionCreated(cycle.Start, TransactionType.ClientEscrow, clientEscrowTx.GetHash(), correlation);
// Tracker.TransactionCreated(cycle.Start, TransactionType.ClientEscrow, clientEscrowTx.GetHash(), correlation);
services
.
Track
(
escrowTxOut
.
ScriptPubKey
);
services
.
Track
(
escrowTxOut
.
ScriptPubKey
);
var
redeemDestination
=
this
.
OriginWallet
.
GetAccountsByCoinType
(
this
.
coinType
).
First
().
GetFirstUnusedReceivingAddress
().
ScriptPubKey
;
// Services.WalletService.GenerateAddress().ScriptPubKey;
var
redeemDestination
=
this
.
OriginWallet
.
GetAccountsByCoinType
(
this
.
coinType
).
First
().
GetFirstUnusedReceivingAddress
().
ScriptPubKey
;
// Services.WalletService.GenerateAddress().ScriptPubKey;
var
redeemTx
=
session
.
SolverClientSession
.
CreateRedeemTransaction
(
feeRate
,
redeemDestination
);
var
redeemTx
=
session
.
SolverClientSession
.
CreateRedeemTransaction
(
feeRate
,
redeemDestination
);
...
@@ -106,7 +108,6 @@ namespace Breeze.TumbleBit.Client
...
@@ -106,7 +108,6 @@ namespace Breeze.TumbleBit.Client
//redeemTx does not be to be recorded to the tracker, this is TrustedBroadcastService job
//redeemTx does not be to be recorded to the tracker, this is TrustedBroadcastService job
services
.
Broadcast
(
clientEscrowTx
);
services
.
Broadcast
(
clientEscrowTx
);
services
.
TrustedBroadcast
(
cycle
.
Start
,
TransactionType
.
ClientRedeem
,
correlation
,
redeemTx
);
services
.
TrustedBroadcast
(
cycle
.
Start
,
TransactionType
.
ClientRedeem
,
correlation
,
redeemTx
);
logger
.
LogInformation
(
"Client escrow broadcasted "
+
clientEscrowTx
.
GetHash
());
logger
.
LogInformation
(
"Client escrow broadcasted "
+
clientEscrowTx
.
GetHash
());
...
@@ -133,6 +134,11 @@ namespace Breeze.TumbleBit.Client
...
@@ -133,6 +134,11 @@ namespace Breeze.TumbleBit.Client
}
}
}
}
break
;
break
;
// in this phase, Bob now opens a channel with the tumbler by sending the unblinded voucher he received from Alice.
// at this point, the tumbler knows that there is an Alice somewhere that wants to tumble with Bob.
// the tumbler then creates a new transaction that spends the money and sends it to Bob.
// but the transaction is locked and Bob doesn't know the signature.
// to prove to Bob that behind the lock there is a signature, the tumbler uses the puzzle promise protocol.
case
CyclePhase
.
TumblerChannelEstablishment
:
case
CyclePhase
.
TumblerChannelEstablishment
:
if
(
session
.
ClientChannelNegotiation
!=
null
&&
session
.
ClientChannelNegotiation
.
Status
==
TumblerClientSessionStates
.
WaitingGenerateTumblerTransactionKey
)
if
(
session
.
ClientChannelNegotiation
!=
null
&&
session
.
ClientChannelNegotiation
.
Status
==
TumblerClientSessionStates
.
WaitingGenerateTumblerTransactionKey
)
{
{
...
@@ -159,6 +165,8 @@ namespace Breeze.TumbleBit.Client
...
@@ -159,6 +165,8 @@ namespace Breeze.TumbleBit.Client
logger
.
LogInformation
(
"Tumbler escrow broadcasted "
+
session
.
PromiseClientSession
.
EscrowedCoin
.
Outpoint
.
Hash
);
logger
.
LogInformation
(
"Tumbler escrow broadcasted "
+
session
.
PromiseClientSession
.
EscrowedCoin
.
Outpoint
.
Hash
);
}
}
break
;
break
;
// the tumbler then creates 2 transactions: an escrow transaction and a redeem transaction (in case things don't go as planned with Bob)
case
CyclePhase
.
PaymentPhase
:
case
CyclePhase
.
PaymentPhase
:
if
(
session
.
PromiseClientSession
!=
null
)
if
(
session
.
PromiseClientSession
!=
null
)
{
{
...
@@ -219,6 +227,7 @@ namespace Breeze.TumbleBit.Client
...
@@ -219,6 +227,7 @@ namespace Breeze.TumbleBit.Client
}
}
}
}
break
;
break
;
// now Bob can unlock the signature of the transaction and broadcast it to take his coin.
case
CyclePhase
.
ClientCashoutPhase
:
case
CyclePhase
.
ClientCashoutPhase
:
if
(
session
.
SolverClientSession
!=
null
)
if
(
session
.
SolverClientSession
!=
null
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment