Skip to content

Commit bae7049

Browse files
committed
feat: improve StrKey
1 parent 17817c4 commit bae7049

8 files changed

Lines changed: 603 additions & 126 deletions

File tree

StellarDotnetSdk.Tests/LedgerEntryTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ public void TestConfigSettingContractLedgerCostV0()
12931293
Assert.AreEqual(xdrConfigSetting.LedgerMaxWriteBytes.InnerValue, decodedConfigSetting.LedgerMaxWriteBytes);
12941294
Assert.AreEqual(xdrConfigSetting.TxMaxDiskReadEntries.InnerValue,
12951295
decodedConfigSetting.TxMaxReadLedgerEntries);
1296-
Assert.AreEqual(xdrConfigSetting.TxMaxDiskReadEntries.InnerValue, decodedConfigSetting.TxMaxReadBytes);
1296+
Assert.AreEqual(xdrConfigSetting.TxMaxDiskReadBytes.InnerValue, decodedConfigSetting.TxMaxReadBytes);
12971297
Assert.AreEqual(xdrConfigSetting.TxMaxWriteLedgerEntries.InnerValue,
12981298
decodedConfigSetting.TxMaxWriteLedgerEntries);
12991299
Assert.AreEqual(xdrConfigSetting.TxMaxWriteBytes.InnerValue, decodedConfigSetting.TxMaxWriteBytes);

StellarDotnetSdk.Tests/Operations/SetOptionsOperationTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public void TestPayloadSignerKey()
176176

177177

178178
var payload = Util.HexToBytes("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20");
179-
var signedPayloadSigner = new SignedPayloadSigner(StrKey.DecodeStellarAccountId(payloadSignerStrKey), payload);
179+
var signedPayloadSigner = new SignedPayloadSigner(StrKey.DecodeEd25519PublicKey(payloadSignerStrKey), payload);
180180
var signerKey = SignerUtil.SignedPayload(signedPayloadSigner);
181181
var operation = new SetOptionsOperation(_source)
182182
.SetSigner(signerKey, 1);

StellarDotnetSdk.Tests/SignedPayloadSignerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ public void ItFailsWhenPayloadLengthTooBig()
2020
var payload = Util.HexToBytes(
2121
"0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f200102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2001");
2222
Assert.ThrowsException<ArgumentException>(() =>
23-
new SignedPayloadSigner(StrKey.DecodeStellarAccountId(accountStrKey), payload));
23+
new SignedPayloadSigner(StrKey.DecodeEd25519PublicKey(accountStrKey), payload));
2424
}
2525
}

StellarDotnetSdk.Tests/SignerTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public void ItCreatesSignedPayloadSigner()
1212
const string accountStrKey = "GA7QYNF7SOWQ3GLR2BGMZEHXAVIRZA4KVWLTJJFC7MGXUA74P7UJVSGZ";
1313

1414
var payload = Util.HexToBytes("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20");
15-
var signedPayloadSigner = new SignedPayloadSigner(StrKey.DecodeStellarAccountId(accountStrKey), payload);
15+
var signedPayloadSigner = new SignedPayloadSigner(StrKey.DecodeEd25519PublicKey(accountStrKey), payload);
1616
var signerKey = SignerUtil.SignedPayload(signedPayloadSigner);
1717

1818
Assert.IsTrue(signerKey.Ed25519SignedPayload.Payload.SequenceEqual(payload));

StellarDotnetSdk.Tests/StrKeyTest.cs

Lines changed: 216 additions & 39 deletions
Large diffs are not rendered by default.

StellarDotnetSdk.Tests/Transactions/TransactionPreconditionsTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void ItConvertsToV2Xdr()
9393
Ed25519SignedPayload = new xdrSDK.SignerKey.SignerKeyEd25519SignedPayload
9494
{
9595
Ed25519 = new xdrSDK.Uint256(
96-
StrKey.DecodeStellarAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR")),
96+
StrKey.DecodeEd25519PublicKey("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR")),
9797
Payload = payload,
9898
},
9999
};

StellarDotnetSdk/Accounts/KeyPair.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public KeyPair(byte[] publicKey, byte[]? privateKey, byte[]? seed)
7474
/// <summary>
7575
/// SecretSeed
7676
/// </summary>
77-
public string? SecretSeed => SeedBytes != null ? StrKey.EncodeStellarSecretSeed(SeedBytes) : null;
77+
public string? SecretSeed => SeedBytes != null ? StrKey.EncodeEd25519SecretSeed(SeedBytes) : null;
7878

7979
/// <summary>
8080
/// XDR Signature Hint
@@ -143,7 +143,7 @@ public SignerKey XdrSignerKey
143143
/// <summary>
144144
/// AccountId
145145
/// </summary>
146-
public string AccountId => StrKey.EncodeStellarAccountId(PublicKey);
146+
public string AccountId => StrKey.EncodeEd25519PublicKey(PublicKey);
147147

148148
/// <summary>
149149
/// Address
@@ -233,7 +233,7 @@ public bool CanSign()
233233
/// </returns>
234234
public static KeyPair FromSecretSeed(string seed)
235235
{
236-
var bytes = StrKey.DecodeStellarSecretSeed(seed);
236+
var bytes = StrKey.DecodeEd25519SecretSeed(seed);
237237
return FromSecretSeed(bytes);
238238
}
239239

@@ -261,7 +261,7 @@ public static KeyPair FromSecretSeed(byte[] seed)
261261
/// </returns>
262262
public static KeyPair FromAccountId(string accountId)
263263
{
264-
var decoded = StrKey.DecodeStellarAccountId(accountId);
264+
var decoded = StrKey.DecodeEd25519PublicKey(accountId);
265265
return FromPublicKey(decoded);
266266
}
267267

0 commit comments

Comments
 (0)