Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Commit

Permalink
Multisig wallet (#26)
Browse files Browse the repository at this point in the history
* Removed classes and interfaces that can be from the wallet feature

* remove some unused controller methods

* ChainCode and Multisig HD operations

* made accounts non-hd

* Move the import key to the GPW

* integrated the multisig wallet to the federation feature

* Included Federation multisig tests

* merge2

* updated settings

* split wallet object
  • Loading branch information
bokobza authored and monsieurleberre committed Jun 15, 2018
1 parent 236edbb commit ca6330a
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 101 deletions.
4 changes: 2 additions & 2 deletions Helpers/ApiCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ public static async Task<string> UnusedAddress(int apiPortForSidechain, string w
}
}

public static async Task CreateGeneralPurposeWallet(int apiPortForSidechain, string walletName,
public static async Task CreateFederationWallet(int apiPortForSidechain, string walletName,
string password)
{
var walletCreationRequest = new Stratis.Bitcoin.Features.GeneralPurposeWallet.Models.WalletCreationRequest()
var walletCreationRequest = new WalletCreationRequest()
{
Name = walletName,
Password = password
Expand Down
21 changes: 11 additions & 10 deletions Helpers/IntegrationTestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
using System.Threading.Tasks;
using NBitcoin;
using Stratis.Bitcoin.Connection;
using Stratis.Bitcoin.Features.GeneralPurposeWallet;
using Stratis.Bitcoin.Features.GeneralPurposeWallet.Interfaces;
using Stratis.Bitcoin.Features.Wallet.Interfaces;
using Stratis.Bitcoin.IntegrationTests.Common.EnvironmentMockUpHelpers;
using Stratis.Bitcoin.P2P.Peer;
using Stratis.FederatedPeg.Features.FederationGateway.Interfaces;
using Stratis.FederatedPeg.Features.FederationGateway.Wallet;

//using CoreNode = Stratis.Bitcoin.

Expand Down Expand Up @@ -102,9 +103,9 @@ public static bool AreNodesSynced(CoreNode node1, CoreNode node2)
return true;
}

private static IGeneralPurposeWalletManager GetGeneralWalletManager(CoreNode node)
private static IFederationWalletManager GetGeneralWalletManager(CoreNode node)
{
return node.FullNode.NodeService<IGeneralPurposeWalletManager>();
return node.FullNode.NodeService<IFederationWalletManager>();
}

public static bool AreNodeGeneralWalletsSynced(CoreNode node1, CoreNode node2)
Expand All @@ -114,22 +115,22 @@ public static bool AreNodeGeneralWalletsSynced(CoreNode node1, CoreNode node2)

public static void ResyncGeneralWallet(CoreNode node)
{
var generalPurposeWalletSyncManager = node.FullNode.NodeService<IGeneralPurposeWalletSyncManager>();
generalPurposeWalletSyncManager.SyncFromHeight(0);
var federationWalletSyncManager = node.FullNode.NodeService<IFederationWalletSyncManager>();
federationWalletSyncManager.SyncFromHeight(0);
}

public static bool IsGeneralWalletSyncedToHeight(CoreNode node, int height)
{
var generalWalletManager = node.FullNode.NodeService<IGeneralPurposeWalletManager>() as GeneralPurposeWalletManager;
var generalWalletManager = node.FullNode.NodeService<IFederationWalletManager>() as FederationWalletManager;
return generalWalletManager.LastBlockHeight() >= height;
}

//todo: duplication
public static void SaveGeneralWallet(CoreNode node, string walletName)
{
var generalWalletManager = node.FullNode.NodeService<IGeneralPurposeWalletManager>() as GeneralPurposeWalletManager;
var wallet = generalWalletManager.GetWallet(walletName);
generalWalletManager.SaveWallet(wallet);
var generalWalletManager = node.FullNode.NodeService<IFederationWalletManager>() as FederationWalletManager;
var wallet = generalWalletManager.GetWallet();
generalWalletManager.SaveWallet();
}

public static bool AreConnected(CoreNode node1, CoreNode node2)
Expand Down
24 changes: 10 additions & 14 deletions Helpers/TestFederationFolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
using System.Linq;
using System.Runtime.CompilerServices;
using NBitcoin;
using NBitcoin.DataEncoders;using Stratis.Bitcoin.Features.GeneralPurposeWallet;
using Stratis.Bitcoin.Features.GeneralPurposeWallet.Interfaces;

using Stratis.Bitcoin.Features.Wallet;
using Stratis.Bitcoin.Tests.Common;using Stratis.Bitcoin.IntegrationTests.Common;
using Stratis.Bitcoin.IntegrationTests.Common.EnvironmentMockUpHelpers;
using Stratis.FederatedPeg.Features.FederationGateway.Interfaces;
using Stratis.FederatedPeg.Features.FederationGateway.Wallet;

namespace Stratis.FederatedPeg.IntegrationTests.Helpers
{
Expand Down Expand Up @@ -61,15 +60,12 @@ public void DistributeScriptAndAddress(string[] folderNames)
}
}

public GeneralPurposeAccount ImportPrivateKeyToWallet(CoreNode node, string walletName, string walletPassword, string memberName,
public void ImportPrivateKeyToWallet(CoreNode node, string walletName, string walletPassword, string memberName,
string memberPassword, int m, int n, Network network)
{
// Use the GeneralWalletManager and get the API created wallet.
var generalWalletManager = node.FullNode.NodeService<IGeneralPurposeWalletManager>() as GeneralPurposeWalletManager;
var wallet = generalWalletManager.GetWallet(walletName);

// Use the first account.
var account = wallet.GetAccountsByCoinType((Stratis.Bitcoin.Features.GeneralPurposeWallet.CoinType)node.FullNode.Network.Consensus.CoinType).First();
var generalWalletManager = node.FullNode.NodeService<IFederationWalletManager>() as FederationWalletManager;
var wallet = generalWalletManager.GetWallet();

//Decrypt the private key
var chain = network.ToChain();
Expand All @@ -91,16 +87,16 @@ public GeneralPurposeAccount ImportPrivateKeyToWallet(CoreNode node, string wall

//account.ImportMultiSigAddress(multiSigAddress);

generalWalletManager.SaveWallet(wallet);
generalWalletManager.SaveWallet();

return account;
// return account;
}

public void SaveGeneralWallet(CoreNode node, string walletName)
{
var generalWalletManager = node.FullNode.NodeService<IGeneralPurposeWalletManager>() as GeneralPurposeWalletManager;
var wallet = generalWalletManager.GetWallet(walletName);
generalWalletManager.SaveWallet(wallet);
var generalWalletManager = node.FullNode.NodeService<IFederationWalletManager>() as FederationWalletManager;
var wallet = generalWalletManager.GetWallet();
generalWalletManager.SaveWallet();
}
}
}
Loading

0 comments on commit ca6330a

Please sign in to comment.