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
a1e913c0
Commit
a1e913c0
authored
Jun 16, 2017
by
Jeremy Bokobza
Committed by
GitHub
Jun 16, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #101 from bokobza/master
Fee rate for TB
parents
d7ff2da1
16d3e3cb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
ExternalServices.cs
Breeze/src/Breeze.TumbleBit.Client/ExternalServices.cs
+15
-1
PaymentStateMachine.cs
Breeze/src/Breeze.TumbleBit.Client/PaymentStateMachine.cs
+15
-6
No files found.
Breeze/src/Breeze.TumbleBit.Client/ExternalServices.cs
View file @
a1e913c0
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.Text
;
using
NBitcoin
;
using
NTumbleBit
;
using
Stratis.Bitcoin.MemoryPool
;
namespace
Breeze.TumbleBit.Client
{
...
...
@@ -33,7 +34,20 @@ namespace Breeze.TumbleBit.Client
public
FeeRate
GetFeeRate
()
{
return
null
;
decimal
relayFee
=
MempoolValidator
.
MinRelayTxFee
.
FeePerK
.
ToUnit
(
MoneyUnit
.
BTC
);
var
minimumRate
=
new
FeeRate
(
Money
.
Coins
(
relayFee
*
2
),
1000
);
//0.00002000 BTC/kB
var
fallbackFeeRate
=
new
FeeRate
(
Money
.
Satoshis
(
50
),
1
);
//0.00050000 BTC/kB
// TODO add real fee estimation
//var rate = _RPCClient.TryEstimateFeeRate(1) ??
// _RPCClient.TryEstimateFeeRate(2) ??
// _RPCClient.TryEstimateFeeRate(3) ??
// FallBackFeeRate;
//if (rate < MinimumFeeRate)
// rate = MinimumFeeRa
return
fallbackFeeRate
;
}
}
}
Breeze/src/Breeze.TumbleBit.Client/PaymentStateMachine.cs
View file @
a1e913c0
...
...
@@ -54,6 +54,8 @@ namespace Breeze.TumbleBit.Client
FeeRate
feeRate
=
null
;
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
:
if
(
session
.
ClientChannelNegotiation
==
null
)
{
...
...
@@ -69,6 +71,9 @@ namespace Breeze.TumbleBit.Client
logger
.
LogInformation
(
"Registration Complete"
);
}
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
:
if
(
session
.
ClientChannelNegotiation
.
Status
==
TumblerClientSessionStates
.
WaitingTumblerClientTransactionKey
)
{
...
...
@@ -89,16 +94,13 @@ namespace Breeze.TumbleBit.Client
break
;
}
session
.
SolverClientSession
=
session
.
ClientChannelNegotiation
.
SetClientSignedTransaction
(
clientEscrowTx
);
session
.
SolverClientSession
=
session
.
ClientChannelNegotiation
.
SetClientSignedTransaction
(
clientEscrowTx
);
correlation
=
GetCorrelation
(
session
.
SolverClientSession
.
EscrowedCoin
.
ScriptPubKey
);
// Tracker.AddressCreated(cycle.Start, TransactionType.ClientEscrow, escrowTxOut.ScriptPubKey, correlation);
// Tracker.TransactionCreated(cycle.Start, TransactionType.ClientEscrow, clientEscrowTx.GetHash(), correlation);
services
.
Track
(
escrowTxOut
.
ScriptPubKey
);
var
redeemDestination
=
this
.
OriginWallet
.
GetAccountsByCoinType
(
this
.
coinType
).
First
().
GetFirstUnusedReceivingAddress
().
ScriptPubKey
;
// Services.WalletService.GenerateAddress().ScriptPubKey;
var
redeemTx
=
session
.
SolverClientSession
.
CreateRedeemTransaction
(
feeRate
,
redeemDestination
);
...
...
@@ -106,7 +108,6 @@ namespace Breeze.TumbleBit.Client
//redeemTx does not be to be recorded to the tracker, this is TrustedBroadcastService job
services
.
Broadcast
(
clientEscrowTx
);
services
.
TrustedBroadcast
(
cycle
.
Start
,
TransactionType
.
ClientRedeem
,
correlation
,
redeemTx
);
logger
.
LogInformation
(
"Client escrow broadcasted "
+
clientEscrowTx
.
GetHash
());
...
...
@@ -133,6 +134,11 @@ namespace Breeze.TumbleBit.Client
}
}
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
:
if
(
session
.
ClientChannelNegotiation
!=
null
&&
session
.
ClientChannelNegotiation
.
Status
==
TumblerClientSessionStates
.
WaitingGenerateTumblerTransactionKey
)
{
...
...
@@ -159,6 +165,8 @@ namespace Breeze.TumbleBit.Client
logger
.
LogInformation
(
"Tumbler escrow broadcasted "
+
session
.
PromiseClientSession
.
EscrowedCoin
.
Outpoint
.
Hash
);
}
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
:
if
(
session
.
PromiseClientSession
!=
null
)
{
...
...
@@ -219,6 +227,7 @@ namespace Breeze.TumbleBit.Client
}
}
break
;
// now Bob can unlock the signature of the transaction and broadcast it to take his coin.
case
CyclePhase
.
ClientCashoutPhase
:
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