Hi,
I’m getting a ‘Bad Request’ error with the below:
[HttpGet, Route("UserToEscrow")]
public ActionResult UserToEscrow()
{
//ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
TransferTransaction.Version = 2;
// Get the 3 Accounts
var buyerAccount = PrivateKeyAccount.CreateFromPrivateKey("<VALID KEY>", MainNetChainId);
var sellerAccount = PrivateKeyAccount.CreateFromPrivateKey("<VALID KEY>", MainNetChainId);
var dtp = PrivateKeyAccount.CreateFromPrivateKey("<VALID KEY>", MainNetChainId);
// Generate a new Escrow Account
var newAccountSeed = PrivateKeyAccount.GenerateSeed();
PrivateKeyAccount newAccount = PrivateKeyAccount.CreateFromSeed(newAccountSeed, MainNetChainId);
var newAccountAddress = newAccount.Address;
// Set-up Node
var node = new Node(_host);
// Buyer transfers Funds to Escrow Account
TransferTransaction t = new TransferTransaction(buyerAccount.PublicKey, newAccountAddress, Assets.WAVES, 0.01m, "User to DTP Escrow");
t.Sign(buyerAccount);
node.Transfer(buyerAccount, newAccountAddress, Assets.WAVES, 0.01m);
// Sleep for 10 seconds
Thread.Sleep(10000);
// Create the script for 2/3 multi-sig
string script = "let buyerPubKey = base58'" + Base58.Encode(buyerAccount.PublicKey) + "';" +
"let sellerPubKey = base58'" + Base58.Encode(sellerAccount.PublicKey) + "';" +
"let escrowPubKey = base58'" + Base58.Encode(dtp.PublicKey) + "';" +
"let buyerSigned = if(sigVerify(tx.bodyBytes, tx.proofs[0], buyerPubKey)) then 1 else 0;" +
"let sellerSigned = if(sigVerify(tx.bodyBytes, tx.proofs[1], sellerPubKey)) then 1 else 0;" +
"let escrowSigned = if(sigVerify(tx.bodyBytes, tx.proofs[2], escrowPubKey)) then 1 else 0;" +
"buyerSigned + sellerSigned + escrowSigned >= 2";
var byteCode = node.CompileScript(script);
// Broadcast to network
SetScriptTransaction stx = new SetScriptTransaction(newAccount.PublicKey, byteCode, MainNetChainId);
stx.Sign(newAccount);
var test = stx.GetJsonWithSignature();
// ERROR OCCURS ON THIS LINE
node.Broadcast(stx.GetJsonWithSignature());
// Sleep for 10 seconds
Thread.Sleep(10000);
// Transfer Funds from Escrow to Seller
TransferTransaction t1 = new TransferTransaction(newAccount.PublicKey, sellerAccount.Address, Assets.WAVES, 0.01m, "DTP Escrow to Miner");
t1.Sign(buyerAccount);
t1.Sign(newAccount);
var txId = node.Broadcast(t1);
Console.WriteLine(txId);
return Content("Done");
}
The error occurs here:
SetScriptTransaction stx = new SetScriptTransaction(newAccount.PublicKey, byteCode, MainNetChainId);
stx.Sign(newAccount);
var test = stx.GetJsonWithSignature();
// ERROR OCCURS ON THIS LINE
node.Broadcast(stx.GetJsonWithSignature());
Any assistance would be much appreciated.