Commit 569d7dac authored by Jeremy Bokobza's avatar Jeremy Bokobza

Added watch only wallet for use in tumble bit

parent c48d69a5
......@@ -18,6 +18,7 @@ using Stratis.Bitcoin.Miner;
using Stratis.Bitcoin.Notifications;
using Stratis.Bitcoin.Utilities;
using Stratis.Bitcoin.Wallet;
using Stratis.Bitcoin.WatchOnlyWallet;
namespace Breeze.Daemon
{
......@@ -90,6 +91,7 @@ namespace Breeze.Daemon
{
tumblerAddress = tumblerAddress.Replace("-tumbler-uri=", string.Empty);
fullNodeBuilder.UseTumbleBit(new Uri(tumblerAddress));
fullNodeBuilder.UseWatchOnlyWallet();
}
var node = fullNodeBuilder.Build();
......
......@@ -13,11 +13,7 @@ namespace Breeze.TumbleBit.Client
{
return null;
}
public void Track(Script scriptPubkey)
{
}
public bool Broadcast(Transaction tx)
{
return true;
......
......@@ -98,8 +98,8 @@ namespace Breeze.TumbleBit.Client
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);
// Tracker.TransactionCreated(cycle.Start, TransactionType.ClientEscrow, clientEscrowTx.GetHash(), correlation);
this.watchOnlyWalletManager.Watch(escrowTxOut.ScriptPubKey);
var redeemDestination = this.OriginWallet.GetAccountsByCoinType(this.coinType).First().GetFirstUnusedReceivingAddress().ScriptPubKey;// Services.WalletService.GenerateAddress().ScriptPubKey;
var redeemTx = session.SolverClientSession.CreateRedeemTransaction(feeRate, redeemDestination);
......@@ -147,7 +147,7 @@ namespace Breeze.TumbleBit.Client
var tumblerInformation = await this.BobClient.OpenChannelAsync(bobEscrowInformation);
session.PromiseClientSession = session.ClientChannelNegotiation.ReceiveTumblerEscrowedCoin(tumblerInformation);
//Tell to the block explorer we need to track that address (for checking if it is confirmed in payment phase)
services.Track(session.PromiseClientSession.EscrowedCoin.ScriptPubKey);
this.watchOnlyWalletManager.Watch(session.PromiseClientSession.EscrowedCoin.ScriptPubKey);
//Tracker.AddressCreated(cycle.Start, TransactionType.TumblerEscrow, PromiseClientSession.EscrowedCoin.ScriptPubKey, correlation);
//Tracker.TransactionCreated(cycle.Start, TransactionType.TumblerEscrow, PromiseClientSession.EscrowedCoin.Outpoint.Hash, correlation);
......@@ -194,8 +194,8 @@ namespace Breeze.TumbleBit.Client
var offerRedeemAddress = this.OriginWallet.GetAccountsByCoinType(this.coinType).First().GetFirstUnusedReceivingAddress(); // Services.WalletService.GenerateAddress($"Cycle {cycle.Start} Tumbler Redeem").ScriptPubKey);
var offerRedeem = session.SolverClientSession.CreateOfferRedeemTransaction(feeRate, offerRedeemAddress.ScriptPubKey);
//May need to find solution in the fulfillment transaction
services.Track(offerRedeem.PreviousScriptPubKey);
//May need to find solution in the fulfillment transaction
this.watchOnlyWalletManager.Watch(offerRedeem.PreviousScriptPubKey);
//Tracker.AddressCreated(cycle.Start, TransactionType.ClientOfferRedeem, offerRedeemAddress.ScriptPubKey, correlation);
services.TrustedBroadcast(cycle.Start, TransactionType.ClientOfferRedeem, correlation, offerRedeem);
logger.LogInformation("Offer redeem " + offerRedeem.Transaction.GetHash() + " locked until " + offerRedeem.Transaction.LockTime.Height);
......
......@@ -6,6 +6,7 @@ using NBitcoin;
using NTumbleBit.ClassicTumbler;
using Stratis.Bitcoin;
using Stratis.Bitcoin.Wallet;
using Stratis.Bitcoin.WatchOnlyWallet;
namespace Breeze.TumbleBit.Client
{
......@@ -17,6 +18,7 @@ namespace Breeze.TumbleBit.Client
{
private ITumblerService tumblerService;
private readonly IWalletManager walletManager;
private readonly IWatchOnlyWalletManager watchOnlyWalletManager;
private readonly ILogger logger;
private readonly Signals signals;
private readonly ConcurrentChain chain;
......@@ -26,15 +28,16 @@ namespace Breeze.TumbleBit.Client
private ClassicTumblerParameters TumblerParameters { get; set; }
public TumbleBitManager(ILoggerFactory loggerFactory, IWalletManager walletManager, ConcurrentChain chain, Network network, Signals signals)
public TumbleBitManager(ILoggerFactory loggerFactory, IWalletManager walletManager, IWatchOnlyWalletManager watchOnlyWalletManager, ConcurrentChain chain, Network network, Signals signals)
{
this.walletManager = walletManager;
this.watchOnlyWalletManager = watchOnlyWalletManager;
this.chain = chain;
this.signals = signals;
this.network = network;
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
this.tumblingState = new TumblingState(loggerFactory, this.chain, this.walletManager, this.network);
this.tumblingState = new TumblingState(loggerFactory, this.chain, this.walletManager, this.watchOnlyWalletManager, this.network);
}
/// <inheritdoc />
......
......@@ -10,6 +10,7 @@ using NTumbleBit.ClassicTumbler;
using NTumbleBit.PuzzlePromise;
using NTumbleBit.PuzzleSolver;
using Stratis.Bitcoin.Wallet;
using Stratis.Bitcoin.WatchOnlyWallet;
namespace Breeze.TumbleBit.Client
{
......@@ -20,6 +21,7 @@ namespace Breeze.TumbleBit.Client
private readonly ILogger logger;
private readonly ConcurrentChain chain;
private readonly IWalletManager walletManager;
private readonly IWatchOnlyWalletManager watchOnlyWalletManager;
private readonly CoinType coinType;
[JsonProperty("tumblerParameters")]
......@@ -60,11 +62,13 @@ namespace Breeze.TumbleBit.Client
public TumblingState(ILoggerFactory loggerFactory,
ConcurrentChain chain,
IWalletManager walletManager,
IWatchOnlyWalletManager watchOnlyWalletManager,
Network network)
{
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
this.chain = chain;
this.walletManager = walletManager;
this.watchOnlyWalletManager = watchOnlyWalletManager;
this.coinType = (CoinType)network.Consensus.CoinType;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment