Skip to content

Commit

Permalink
Merge pull request stratisproject#161 from fassadlr/api-get-node-address
Browse files Browse the repository at this point in the history
[Tokenless] Get node address
  • Loading branch information
zeptin authored Jan 30, 2020
2 parents a050d08 + 005c688 commit 73040e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TestScripts/RunCA.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ start-process cmd -ArgumentList "/k color 0E && dotnet run -datadir=""$ca_root""
timeout $long_interval_time

Write-Host "Initializing CA..." -foregroundcolor "magenta"
$params = @{ "mnemonic" = "$mnemonic"; "mnemonicPassword" = "$mnemonicPassword"; "coinType" = $coinType; "addressPrefix" = $addressPrefix; "accountId" = $ca_account; "password" = "$ca_password" }
$params = @{ "mnemonic" = "$mnemonic"; "mnemonicPassword" = "$mnemonicPassword"; "coinType" = $coinType; "addressPrefix" = $addressPrefix; "accountId" = $ca_account; "adminPassword" = "$ca_password" }
Write-Host ($params|ConvertTo-Json)
Invoke-WebRequest -Uri https://localhost:5001/api/certificates/initialize_ca -Method post -Body ($params|ConvertTo-Json) -ContentType "application/json-patch+json"
timeout $interval_time
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using NBitcoin;
using Stratis.Bitcoin.Features.MemoryPool.Broadcasting;
using Stratis.Bitcoin.Features.SmartContracts;
using Stratis.Bitcoin.Features.SmartContracts.Models;
using Stratis.Bitcoin.Features.MemoryPool.Broadcasting;
using Stratis.Bitcoin.Utilities;
using Stratis.Bitcoin.Utilities.JsonErrors;
using Stratis.Bitcoin.Utilities.ModelStateErrors;
Expand Down Expand Up @@ -377,11 +377,26 @@ public IActionResult GetCode([FromQuery]string contractAddress)
}
}

[Route("nodeaddress")]
[HttpGet]
public IActionResult GetNodeAddress()
{
try
{
PubKey transactionSigningKey = this.tokenlessWalletManager.GetPubKey(TokenlessWalletAccount.TransactionSigning);
return this.Json(transactionSigningKey.GetAddress(this.coreComponent.Network).ToString());
}
catch (Exception e)
{
this.logger.LogError("Exception occurred: {0}", e.ToString());
return ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString());
}
}

/// <summary>
/// Creates and signs the transaction.
/// </summary>
/// <param name="contractTxData">The contract data to be serialized.</param>
///
/// <returns>The signed transaction</returns>
private Transaction CreateAndSignTransaction(ContractTxData contractTxData)
{
Expand Down

0 comments on commit 73040e9

Please sign in to comment.