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
56c9a9cf
Commit
56c9a9cf
authored
May 12, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added send-transaction
parent
20d4beef
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
11 deletions
+31
-11
WalletController.cs
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
+3
-4
IWalletManager.cs
Breeze/src/Breeze.Wallet/IWalletManager.cs
+6
-1
WalletManager.cs
Breeze/src/Breeze.Wallet/WalletManager.cs
+22
-6
No files found.
Breeze/src/Breeze.Wallet/Controllers/WalletController.cs
View file @
56c9a9cf
...
...
@@ -287,12 +287,11 @@ namespace Breeze.Wallet.Controllers
try
{
var
transaction
=
this
.
walletManager
.
BuildTransaction
(
request
.
WalletName
,
request
.
AccountName
,
request
.
CoinType
,
request
.
Password
,
request
.
DestinationAddress
,
request
.
Amount
,
request
.
FeeType
,
request
.
AllowUnconfirmed
);
var
fee
=
transaction
.
TotalOut
-
request
.
Amount
;
var
transactionResult
=
this
.
walletManager
.
BuildTransaction
(
request
.
WalletName
,
request
.
AccountName
,
request
.
CoinType
,
request
.
Password
,
request
.
DestinationAddress
,
request
.
Amount
,
request
.
FeeType
,
request
.
AllowUnconfirmed
);
var
model
=
new
WalletBuildTransactionModel
{
Hex
=
transaction
.
ToHex
()
,
Fee
=
fee
Hex
=
transaction
Result
.
hex
,
Fee
=
transactionResult
.
fee
};
return
this
.
Json
(
model
);
}
...
...
Breeze/src/Breeze.Wallet/IWalletManager.cs
View file @
56c9a9cf
...
...
@@ -135,8 +135,13 @@ namespace Breeze.Wallet
/// <param name="feeType">The type of fee to be included.</param>
/// <param name="allowUnconfirmed">Whether or not we allow this transaction to rely on unconfirmed outputs.</param>
/// <returns></returns>
NBitcoin
.
Transaction
BuildTransaction
(
string
walletName
,
string
accountName
,
CoinType
coinType
,
string
password
,
string
destinationAddress
,
Money
amount
,
string
feeType
,
bool
allowUnconfirmed
);
(
string
hex
,
Money
fee
)
BuildTransaction
(
string
walletName
,
string
accountName
,
CoinType
coinType
,
string
password
,
string
destinationAddress
,
Money
amount
,
string
feeType
,
bool
allowUnconfirmed
);
/// <summary>
/// Sends a transaction to the network.
/// </summary>
/// <param name="transactionHex">The hex of the transaction.</param>
/// <returns></returns>
bool
SendTransaction
(
string
transactionHex
);
/// <summary>
...
...
Breeze/src/Breeze.Wallet/WalletManager.cs
View file @
56c9a9cf
...
...
@@ -7,7 +7,9 @@ using Breeze.Wallet.Helpers;
using
Breeze.Wallet.Models
;
using
NBitcoin
;
using
NBitcoin.DataEncoders
;
using
NBitcoin.Protocol
;
using
Newtonsoft.Json
;
using
Stratis.Bitcoin.Connection
;
using
Transaction
=
NBitcoin
.
Transaction
;
namespace
Breeze.Wallet
...
...
@@ -31,12 +33,14 @@ namespace Breeze.Wallet
private
readonly
CoinType
coinType
;
private
readonly
ConnectionManager
connectionManager
;
/// <summary>
/// Occurs when a transaction is found.
/// </summary>
public
event
EventHandler
<
TransactionFoundEventArgs
>
TransactionFound
;
public
WalletManager
(
Con
currentChain
chain
,
Network
netwrok
)
public
WalletManager
(
Con
nectionManager
connectionManager
,
Network
netwrok
)
{
this
.
Wallets
=
new
List
<
Wallet
>();
...
...
@@ -46,6 +50,7 @@ namespace Breeze.Wallet
this
.
Load
(
this
.
DeserializeWallet
(
path
));
}
this
.
connectionManager
=
connectionManager
;
this
.
coinType
=
(
CoinType
)
netwrok
.
Consensus
.
CoinType
;
// load data in memory for faster lookups
...
...
@@ -322,7 +327,7 @@ namespace Breeze.Wallet
}
/// <inheritdoc />
public
Transaction
BuildTransaction
(
string
walletName
,
string
accountName
,
CoinType
coinType
,
string
password
,
string
destinationAddress
,
Money
amount
,
string
feeType
,
bool
allowUnconfirmed
)
public
(
string
hex
,
Money
fee
)
BuildTransaction
(
string
walletName
,
string
accountName
,
CoinType
coinType
,
string
password
,
string
destinationAddress
,
Money
amount
,
string
feeType
,
bool
allowUnconfirmed
)
{
if
(
amount
==
Money
.
Zero
)
{
...
...
@@ -385,7 +390,7 @@ namespace Breeze.Wallet
throw
new
Exception
(
"Could not build transaction, please make sure you entered the correct data."
);
}
return
tx
;
return
(
tx
.
ToHex
(),
calculationResult
.
fee
)
;
}
/// <summary>
...
...
@@ -411,9 +416,20 @@ namespace Breeze.Wallet
return
(
transactionsToUse
,
fee
);
}
/// <inheritdoc />
public
bool
SendTransaction
(
string
transactionHex
)
{
throw
new
System
.
NotImplementedException
();
// TODO move this to a behavior on the full node
// parse transaction
Transaction
transaction
=
Transaction
.
Parse
(
transactionHex
);
TxPayload
payload
=
new
TxPayload
(
transaction
);
foreach
(
var
node
in
connectionManager
.
ConnectedNodes
)
{
node
.
SendMessage
(
payload
);
}
return
true
;
}
/// <inheritdoc />
...
...
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