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
3435ae71
Commit
3435ae71
authored
May 30, 2017
by
Jeremy Bokobza
Committed by
GitHub
May 30, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #85 from bokobza/tumble-bit
Added tumbler API methods
parents
5d823d76
4ea339fe
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
142 additions
and
5 deletions
+142
-5
ITumblerService.cs
Breeze/src/Breeze.TumbleBit.Client/ITumblerService.cs
+26
-3
SignVoucherRequest.cs
.../src/Breeze.TumbleBit.Client/Models/SignVoucherRequest.cs
+22
-0
TumblerEscrowKeyResponse.cs
...reeze.TumbleBit.Client/Models/TumblerEscrowKeyResponse.cs
+15
-0
TumblerService.cs
Breeze/src/Breeze.TumbleBit.Client/TumblerService.cs
+79
-2
No files found.
Breeze/src/Breeze.TumbleBit.Client/ITumblerService.cs
View file @
3435ae71
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Breeze.TumbleBit.Models
;
using
NBitcoin
;
using
NTumbleBit
;
using
NTumbleBit
;
using
NTumbleBit.ClassicTumbler
;
using
NTumbleBit.ClassicTumbler
;
using
NTumbleBit.PuzzlePromise
;
using
NTumbleBit.PuzzleSolver
;
using
PuzzlePromise
=
NTumbleBit
.
PuzzlePromise
;
using
PuzzleSolver
=
NTumbleBit
.
PuzzleSolver
;
namespace
Breeze.TumbleBit.Client
namespace
Breeze.TumbleBit.Client
{
{
...
@@ -17,5 +20,25 @@ namespace Breeze.TumbleBit.Client
...
@@ -17,5 +20,25 @@ namespace Breeze.TumbleBit.Client
/// </summary>
/// </summary>
/// <returns></returns>
/// <returns></returns>
Task
<
ClassicTumblerParameters
>
GetClassicTumblerParametersAsync
();
Task
<
ClassicTumblerParameters
>
GetClassicTumblerParametersAsync
();
Task
<
UnsignedVoucherInformation
>
AskUnsignedVoucher
();
Task
<
PuzzleSolution
>
SignVoucherAsync
(
SignVoucherRequest
signVoucherRequest
);
Task
<
ScriptCoin
>
OpenChannelAsync
(
OpenChannelRequest
request
);
Task
<
TumblerEscrowKeyResponse
>
RequestTumblerEscrowKeyAsync
(
int
cycleStart
);
Task
<
ServerCommitmentsProof
>
CheckRevelationAsync
(
int
cycleId
,
string
channelId
,
PuzzlePromise
.
ClientRevelation
revelation
);
Task
<
SolutionKey
[
]>
CheckRevelationAsync
(
int
cycleId
,
string
channelId
,
PuzzleSolver
.
ClientRevelation
revelation
);
Task
<
PuzzlePromise
.
ServerCommitment
[
]>
SignHashesAsync
(
int
cycleId
,
string
channelId
,
SignaturesRequest
sigReq
);
Task
<
OfferInformation
>
CheckBlindFactorsAsync
(
int
cycleId
,
string
channelId
,
BlindFactor
[]
blindFactors
);
Task
<
PuzzleSolver
.
ServerCommitment
[
]>
SolvePuzzlesAsync
(
int
cycleId
,
string
channelId
,
PuzzleValue
[]
puzzles
);
Task
<
SolutionKey
[
]>
FulfillOfferAsync
(
int
cycleId
,
string
channelId
,
TransactionSignature
clientSignature
);
}
}
}
}
Breeze/src/Breeze.TumbleBit.Client/Models/SignVoucherRequest.cs
0 → 100644
View file @
3435ae71
using
NBitcoin
;
using
NTumbleBit.ClassicTumbler
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Breeze.TumbleBit.Models
{
public
class
SignVoucherRequest
{
public
int
KeyReference
{
get
;
set
;
}
public
PubKey
TumblerEscrowPubKey
{
get
;
set
;
}
public
ClientEscrowInformation
ClientEscrowInformation
{
get
;
set
;
}
public
MerkleBlock
MerkleProof
{
get
;
set
;
}
public
Transaction
Transaction
{
get
;
set
;
}
}
}
Breeze/src/Breeze.TumbleBit.Client/Models/TumblerEscrowKeyResponse.cs
0 → 100644
View file @
3435ae71
using
NBitcoin
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading.Tasks
;
namespace
Breeze.TumbleBit.Models
{
public
class
TumblerEscrowKeyResponse
{
public
int
KeyIndex
{
get
;
set
;
}
public
PubKey
PubKey
{
get
;
set
;
}
}
}
Breeze/src/Breeze.TumbleBit.Client/TumblerService.cs
View file @
3435ae71
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
Breeze.TumbleBit.Models
;
using
Flurl
;
using
Flurl
;
using
Flurl.Http
;
using
Flurl.Http
;
using
Flurl.Http.Configuration
;
using
Flurl.Http.Configuration
;
using
NBitcoin
;
using
NBitcoin.JsonConverters
;
using
NBitcoin.JsonConverters
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json
;
using
NTumbleBit
;
using
NTumbleBit.ClassicTumbler
;
using
NTumbleBit.ClassicTumbler
;
using
NTumbleBit.JsonConverters
;
using
NTumbleBit.JsonConverters
;
using
NTumbleBit.PuzzlePromise
;
using
NTumbleBit.PuzzleSolver
;
using
PuzzlePromise
=
NTumbleBit
.
PuzzlePromise
;
using
PuzzleSolver
=
NTumbleBit
.
PuzzleSolver
;
namespace
Breeze.TumbleBit.Client
namespace
Breeze.TumbleBit.Client
{
{
...
@@ -33,5 +40,75 @@ namespace Breeze.TumbleBit.Client
...
@@ -33,5 +40,75 @@ namespace Breeze.TumbleBit.Client
ClassicTumblerParameters
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
"/api/v1/tumblers/0/parameters"
).
GetJsonAsync
<
ClassicTumblerParameters
>();
ClassicTumblerParameters
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
"/api/v1/tumblers/0/parameters"
).
GetJsonAsync
<
ClassicTumblerParameters
>();
return
result
;
return
result
;
}
}
/// <inheritdoc />
public
async
Task
<
UnsignedVoucherInformation
>
AskUnsignedVoucher
()
{
UnsignedVoucherInformation
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
"api/v1/tumblers/0/vouchers/"
).
GetJsonAsync
<
UnsignedVoucherInformation
>();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
PuzzleSolution
>
SignVoucherAsync
(
SignVoucherRequest
request
)
{
PuzzleSolution
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
"api/v1/tumblers/0/clientchannels/confirm"
).
PostJsonAsync
(
request
).
ReceiveJson
<
PuzzleSolution
>();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
ScriptCoin
>
OpenChannelAsync
(
OpenChannelRequest
request
)
{
ScriptCoin
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
"api/v1/tumblers/0/channels/"
).
PostJsonAsync
(
request
).
ReceiveJson
<
ScriptCoin
>();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
TumblerEscrowKeyResponse
>
RequestTumblerEscrowKeyAsync
(
int
cycleStart
)
{
TumblerEscrowKeyResponse
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
"api/v1/tumblers/0/clientchannels/"
).
PostJsonAsync
(
cycleStart
).
ReceiveJson
<
TumblerEscrowKeyResponse
>();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
ServerCommitmentsProof
>
CheckRevelationAsync
(
int
cycleId
,
string
channelId
,
PuzzlePromise
.
ClientRevelation
revelation
)
{
ServerCommitmentsProof
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
$"api/v1/tumblers/0/channels/
{
cycleId
}
/
{
channelId
}
/checkrevelation"
).
PostJsonAsync
(
revelation
).
ReceiveJson
<
ServerCommitmentsProof
>();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
SolutionKey
[
]>
CheckRevelationAsync
(
int
cycleId
,
string
channelId
,
PuzzleSolver
.
ClientRevelation
revelation
)
{
SolutionKey
[]
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
$"api/v1/tumblers/0/clientschannels/
{
cycleId
}
/
{
channelId
}
/checkrevelation"
).
PostJsonAsync
(
revelation
).
ReceiveJson
<
SolutionKey
[
]>
();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
PuzzlePromise
.
ServerCommitment
[
]>
SignHashesAsync
(
int
cycleId
,
string
channelId
,
SignaturesRequest
sigReq
)
{
PuzzlePromise
.
ServerCommitment
[]
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
$"api/v1/tumblers/0/channels/
{
cycleId
}
/
{
channelId
}
/signhashes"
).
PostJsonAsync
(
sigReq
).
ReceiveJson
<
PuzzlePromise
.
ServerCommitment
[
]>
();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
OfferInformation
>
CheckBlindFactorsAsync
(
int
cycleId
,
string
channelId
,
BlindFactor
[]
blindFactors
)
{
OfferInformation
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
$"api/v1/tumblers/0/clientschannels/
{
cycleId
}
/
{
channelId
}
/checkblindfactors"
).
PostJsonAsync
(
blindFactors
).
ReceiveJson
<
OfferInformation
>();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
PuzzleSolver
.
ServerCommitment
[
]>
SolvePuzzlesAsync
(
int
cycleId
,
string
channelId
,
PuzzleValue
[]
puzzles
)
{
PuzzleSolver
.
ServerCommitment
[]
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
$"api/v1/tumblers/0/clientchannels/
{
cycleId
}
/
{
channelId
}
/solvepuzzles"
).
PostJsonAsync
(
puzzles
).
ReceiveJson
<
PuzzleSolver
.
ServerCommitment
[
]>
();
return
result
;
}
/// <inheritdoc />
public
async
Task
<
SolutionKey
[
]>
FulfillOfferAsync
(
int
cycleId
,
string
channelId
,
TransactionSignature
clientSignature
)
{
SolutionKey
[]
result
=
await
this
.
serverAddress
.
AppendPathSegment
(
$"api/v1/tumblers/0/clientchannels/
{
cycleId
}
/
{
channelId
}
/offer"
).
PostJsonAsync
(
clientSignature
).
ReceiveJson
<
SolutionKey
[
]>
();
return
result
;
}
}
}
}
}
\ No newline at end of file
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