Skip to content

Commit

Permalink
updated to latest IxiCore
Browse files Browse the repository at this point in the history
  • Loading branch information
IxiAngel committed Sep 22, 2021
1 parent 5a05041 commit 7c4012c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
15 changes: 7 additions & 8 deletions IxianLiteWallet/Commands/Commands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ void handleBalance()

void handleAddress()
{
Console.WriteLine("Primary address: {0}\n", Base58Check.Base58CheckEncoding.EncodePlain(Node.walletStorage.getPrimaryAddress()));
Console.WriteLine("Primary address: {0}\n", Base58Check.Base58CheckEncoding.EncodePlain(IxianHandler.getWalletStorage().getPrimaryAddress()));
}

void handleAddresses()
{
List<Address> address_list = Node.walletStorage.getMyAddresses();
List<Address> address_list = IxianHandler.getWalletStorage().getMyAddresses();

foreach (Address addr in address_list)
{
Expand All @@ -127,7 +127,7 @@ void handleAddresses()
void handleBackup()
{
List<byte> wallet = new List<byte>();
wallet.AddRange(Node.walletStorage.getRawWallet());
wallet.AddRange(IxianHandler.getWalletStorage().getRawWallet());
Console.WriteLine("IXIHEX" + Crypto.hashToString(wallet.ToArray()));
Console.WriteLine("");
}
Expand All @@ -151,8 +151,7 @@ void handleChangePass()
}

// Read the wallet using the provided password
Node.walletStorage = new WalletStorage(Config.walletFile);
if (Node.walletStorage.readWallet(password))
if (IxianHandler.getWalletStorage().isValidPassword(password))
{
success = true;
}
Expand All @@ -171,7 +170,7 @@ void handleChangePass()
continue;
}
}
if (Node.walletStorage.writeWallet(new_password))
if (IxianHandler.getWalletStorage().writeWallet(new_password))
Console.WriteLine("Wallet password changed.");
}

Expand Down Expand Up @@ -278,8 +277,8 @@ void handleStress(string line)
{
IxiNumber amount = ConsensusConfig.transactionPrice;
IxiNumber fee = ConsensusConfig.transactionPrice;
byte[] from = Node.walletStorage.getPrimaryAddress();
byte[] pubKey = Node.walletStorage.getPrimaryPublicKey();
byte[] from = IxianHandler.getWalletStorage().getPrimaryAddress();
byte[] pubKey = IxianHandler.getWalletStorage().getPrimaryPublicKey();

long start_time = Clock.getTimestampMillis();
int spam_counter = 0;
Expand Down
22 changes: 14 additions & 8 deletions IxianLiteWallet/Meta/Node.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class Node : IxianNode
{
public static bool running = false;

public static WalletStorage walletStorage;

public static Balance balance = new Balance(); // Stores the last known balance for this node

public static TransactionInclusion tiv = null;
Expand Down Expand Up @@ -65,7 +63,7 @@ private void init()

private bool initWallet()
{
walletStorage = new WalletStorage(Config.walletFile);
WalletStorage walletStorage = new WalletStorage(Config.walletFile);

Logging.flush();

Expand Down Expand Up @@ -137,6 +135,14 @@ private bool initWallet()
return false;
}

if (walletStorage.viewingWallet)
{
Logging.error("Viewing-only wallet {0} cannot be used as the primary DLT Node wallet.", Base58Check.Base58CheckEncoding.EncodePlain(walletStorage.getPrimaryAddress()));
return false;
}

IxianHandler.addWallet(walletStorage);

return true;
}

Expand Down Expand Up @@ -165,7 +171,7 @@ public void start()
NetworkClientManager.start(2);

// Start TIV
if (generatedNewWallet || !walletStorage.walletExists())
if (generatedNewWallet || !File.Exists(Config.walletFile))
{
generatedNewWallet = false;
tiv.start("");
Expand All @@ -185,8 +191,8 @@ static public void getBalance()
{
using (BinaryWriter writer = new BinaryWriter(mw))
{
writer.WriteIxiVarInt(Node.walletStorage.getPrimaryAddress().Length);
writer.Write(Node.walletStorage.getPrimaryAddress());
writer.WriteIxiVarInt(IxianHandler.getWalletStorage().getPrimaryAddress().Length);
writer.Write(IxianHandler.getWalletStorage().getPrimaryAddress());
NetworkClientManager.broadcastData(new char[] { 'M', 'H' }, ProtocolMessageCode.getBalance2, mw.ToArray(), null);
}
}
Expand All @@ -206,8 +212,8 @@ static public void sendTransaction(string address, IxiNumber amount)
SortedDictionary<byte[], IxiNumber> to_list = new SortedDictionary<byte[], IxiNumber>(new ByteArrayComparer());

IxiNumber fee = ConsensusConfig.transactionPrice;
byte[] from = Node.walletStorage.getPrimaryAddress();
byte[] pubKey = Node.walletStorage.getPrimaryPublicKey();
byte[] from = IxianHandler.getWalletStorage().getPrimaryAddress();
byte[] pubKey = IxianHandler.getWalletStorage().getPrimaryPublicKey();
to_list.AddOrReplace(Base58Check.Base58CheckEncoding.DecodePlain(address), amount);
Transaction transaction = new Transaction((int)Transaction.Type.Normal, fee, to_list, from, null, pubKey, IxianHandler.getHighestKnownNetworkBlockHeight());
if (IxianHandler.addTransaction(transaction, true))
Expand Down
4 changes: 2 additions & 2 deletions IxianLiteWallet/Network/NetworkProtocol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public static void parseProtocolMessage(ProtocolMessageCode code, byte[] data, R
// Retrieve the latest balance
IxiNumber balance = new IxiNumber(reader.ReadString());

if (address.SequenceEqual(Node.walletStorage.getPrimaryAddress()))
if (address.SequenceEqual(IxianHandler.getWalletStorage().getPrimaryAddress()))
{
// Retrieve the blockheight for the balance
ulong block_height = reader.ReadUInt64();
Expand Down Expand Up @@ -150,7 +150,7 @@ public static void parseProtocolMessage(ProtocolMessageCode code, byte[] data, R
// Retrieve the latest balance
IxiNumber balance = new IxiNumber(new BigInteger(balance_bytes));

if (address.SequenceEqual(Node.walletStorage.getPrimaryAddress()))
if (address.SequenceEqual(IxianHandler.getWalletStorage().getPrimaryAddress()))
{
// Retrieve the blockheight for the balance
ulong block_height = reader.ReadIxiVarUInt();
Expand Down

0 comments on commit 7c4012c

Please sign in to comment.