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
a464e3f1
Commit
a464e3f1
authored
May 30, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added api methods
parent
34f2bdc4
Hide 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
+27
-4
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
+78
-1
No files found.
Breeze/src/Breeze.TumbleBit.Client/ITumblerService.cs
View file @
a464e3f1
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.ClassicTumbler
;
using
NTumbleBit.PuzzlePromise
;
using
NTumbleBit.PuzzleSolver
;
using
PuzzlePromise
=
NTumbleBit
.
PuzzlePromise
;
using
PuzzleSolver
=
NTumbleBit
.
PuzzleSolver
;
namespace
Breeze.TumbleBit.Client
{
...
...
@@ -17,5 +20,25 @@ namespace Breeze.TumbleBit.Client
/// </summary>
/// <returns></returns>
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 @
a464e3f1
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 @
a464e3f1
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 @
a464e3f1
using
System
;
using
System.Collections.Generic
;
using
System.Threading.Tasks
;
using
Breeze.TumbleBit.Models
;
using
Flurl
;
using
Flurl.Http
;
using
Flurl.Http.Configuration
;
using
NBitcoin
;
using
NBitcoin.JsonConverters
;
using
Newtonsoft.Json
;
using
NTumbleBit
;
using
NTumbleBit.ClassicTumbler
;
using
NTumbleBit.JsonConverters
;
using
NTumbleBit.PuzzlePromise
;
using
NTumbleBit.PuzzleSolver
;
using
PuzzlePromise
=
NTumbleBit
.
PuzzlePromise
;
using
PuzzleSolver
=
NTumbleBit
.
PuzzleSolver
;
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
>();
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