Can anyone help me out with block.io API for withdrawal of bitcoin from wallet? - api

I am trying to use block.io API, before few months I tried and implemented, it was working perfect, and now they have changed signed signature method, All APIs working correct, only withdrawal API not working, Response of curl is showing success, but says required more_signatures_needed , I don't know how to do this, Can anyone help me? I will be thankful.
protected void Page_Load(object sender, EventArgs e)
{
myPage.Text = readHtmlPage("https://block.io/api/v2/withdraw_from_addresses/");
//fecth response
String myUri = Session["myPagecc"].ToString();
//display response
Label1.Text = myUri.ToString();
}
private String readHtmlPage(string url)
{
String api_key = "myapikey";
double amounts = "btcamount";
String to_addresses = "receiveraddress";
string FROM_ADDRESS = "myaddress";
string NEWCODE = Guid.NewGuid().ToString().Substring(0, 5);
string priority="medium";
String result = "";
String strPost = "api_key=" + api_key + "&from_addresses=" + FROM_ADDRESS + "&to_addresses="+to_addresses +"&amounts="+amounts+"&priority="+priority+"&nonce="+NEWCODE;
StreamWriter myWriter = null;
HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);
objRequest.Method = "POST";
objRequest.ContentLength = strPost.Length;
objRequest.ContentType = "application/x-www-form-urlencoded";
try
{
myWriter = new StreamWriter(objRequest.GetRequestStream());
myWriter.Write(strPost);
}
catch (Exception e)
{
return e.Message;
}
finally
{
myWriter.Close();
}
HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
using (StreamReader sr =
new StreamReader(objResponse.GetResponseStream()))
{
result = sr.ReadToEnd();
// Close and clean up the StreamReader
sr.Close();
}
return result;
}
"status" : "success", "data" : { "reference_id" : "70ab0922cf036481533e7f345068c0bed36f9681d644d8", "more_signatures_needed" : true, "inputs" : [ { "input_no" : 0, "signatures_needed" : 1, "data_to_sign" : "3916022666e29882298d54c2c8f2ab3306cc4e774594f5db9", "signers" : [ { "signer_address" : "jhE397dsNaNLByJ8WV43emD1mhSpPtwDV", "signer_public_key" : "a34b48a3a18373020d8d96fb53b733d373cd3ba9b5bbfd2c9f8105c8939058130d", "signed_data" : null } ] } ], "encrypted_passphrase" : { "signer_address" : "NaNLmhSByJ8WV43emD1jhE397dspPtwDV", "signer_public_key" : "373cd3ba9b5bbfd2c9f8020d8d96fb53b733d373a34b48a3a18105c8939058130d", "passphrase" : "r20/Wyy5iTVFmpcmn1Y8JOMR8mP7jAqaBrMf2UOW2aEBQSQ1XfxpgonIyFLDOKkmuqH84sETSjXTFsl3dpo5niABB2rL69vnsLbS4DaXMw1o33NH0zgHyzdkAYmIoeGe85YVPMkrQsNhLrGQ6JUaubT+W3rIBxP7rCqYznnMnt8QxG4wu5LSh2EY8fja6AI1" }, "unsigned_tx_hex" : "010000000127d8d4654bc8cf69c9b1980c1afa67e51b5b28241ac080100000023220020200d0c2118ad382e8dab4f3c2ddf5ab8ca1d8ac3ffa3d910a0a2aa86cb69cb77bb62e2a7f12fbc8a699ffffffff076a914103ee4139219756a503842b0ad01000000000019caf5a381440b66bd81188ac64a401000000000017a9145af1577250a83928e306b35f8463047d72d9e3408700000000" } }

Any solution for this please.
With Block.IO token withdrawal it seems we need to send some extra secure pins
as per their doc: https://block.io/api/simple/signing
Like to know how to send cURL to execute ?
Their sample cURL is not working: /api/v2/withdraw_from_addresses/?api_key=API KEY&from_addresses=ADDRESS1,ADDRESS2,...&to_addresses=ADDRESS1,ADDRESS2,...&amounts=AMOUNT1,AMOUNT2,...
response is:
{[status, success]}
{[data, {
"reference_id": "24fe5a.....",
"more_signatures_needed": true,
"inputs": [
{
"input_no": 0,
"signatures_needed": 1,
"data_to_sign": "2498d....",
"signers": [
{
"signer_address": "1H4.....",
"signer_public_key": "037710.....",
"signed_data": null
}
]
}
],
"encrypted_passphrase": {
"signer_address": "1H4...",
"signer_public_key": "0377....",
"passphrase": "fDCM0...."
},
"unsigned_tx_hex": "01000...."
}]}
if possible: expecting some sample in asp.net vb please

Related

I'm creating an erp connector for a company with google data studio, but I don't know how this process works

const cc = DataStudioApp.createCommunityConnector();
function getAuthType() {
return cc.newAuthTypeResponse()
.setAuthType(cc.AuthType.USER_TOKEN)
.setHelpUrl('https://api.sigecloud.com.br/swagger/ui/index#/')
.build();
}
function resetAuth() {
var userTokenProperties = PropertiesService.getUserProperties();
userTokenProperties.deleteProperty('dscc.username');
userTokenProperties.deleteProperty('dscc.password');
}
function isAuthValid() {
var userProperties = PropertiesService.getUserProperties();
var userName = userProperties.getProperty('dscc.username');
var token = userProperties.getProperty('dscc.token');
var res = UrlFetchApp.fetch(`https://api.sigecloud.com.br/request/Pedidos/GetTodosPedidos&Authorization-Token${token}&User=${userName}&page=12&App=API APP`, { 'muteHttpExceptions': true });
return res.getResponseCode() == 200;
}
function getConfig() {
}
function getSchema() {
}
function getData() {
}
This is Manifest:
{
"timeZone": "America/Sao_Paulo",
"dependencies": {},
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"dataStudio":{
"name": "Two Dogs Connector with Sige",
"description": "The unofficial conecctor to acess Sige Data",
"company": "Mateus C Rocha",
"logoUrl": "https://images.sympla.com.br/62ea7b9d69ec5.png",
"addOnUrl": "https://twodogs.com/br/quem-somos/",
"supportUrl": "https://twodogs.com/br/quem-somos/"
}
}
This error appears when I add the implementation ID generated when I select the test implementation option, in the google script
My api needs to receive: Page, user(constant value), token(constant value) and App(constant value)...
I don't know how it works, but I was hoping it wouldn't show errors, as I followed the documentation https://developers.google.com/looker-studio/connector/get-started

Hangouts Chat Bot "The caller does not have permission", PERMISSION_DENIED

I created a chat bot using the JAVA Api, based on the sample code from the documentation,
the Bot uses a service account.
The Bot works fine in one Room, but when I try to use it with a new Room I am experiencing an error.
After adding the Bot to the new Room and trying to post a message I receive
{ "code" : 403, "errors" : [ { "domain" : "global", "message" : "The caller does not have permission", "reason" : "forbidden" } ], "message" : "The caller does not have permission", "status" : "PERMISSION_DENIED" }
Is there any additional step necessary after adding the Bot to a room before posting messages ?
Any help with this problem would be greatly appreciated!
Code used:
HttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory jsonFactory = new JacksonFactory();
HangoutsChat.Builder builder = new HangoutsChat.Builder(httpTransport, jsonFactory, credentials);
builder.setApplicationName(bot);
HangoutsChat service = builder.build();
ListSpacesResponse response = service.spaces().list().execute();
// Look for space Space _space = null;
while (response.getSpaces() != null && _space == null) {
for(Space s : response.getSpaces()) {
if(s.getDisplayName().equals(space)) {
_space = s;
}
}
if (_space == null && response.getNextPageToken() != null && !response.getNextPageToken().isEmpty()) {
String pageToken = response.getNextPageToken();
response = service.spaces().list().setPageToken(pageToken).execute();
} else {
break;
}
}
if(_space != null) {
Message m = new Message();
byte[] data = {0x0A};
m.setText(text.replace("\\r", "").replace("\\n", new String(data)));
Message r = service.spaces().messages().create(_space.getName(), m).setThreadKey(thread).execute();
Element el = new Element("message");
el.setAttribute("space", r.getSpace().getDisplayName());
el.setAttribute("text", r.getText());
el.setAttribute("thread", r.getThread().getName());
outNode.addContent(el);
} else {
throw new Exception("SendHangouts failed " + "Space " + space + " not found");
}

How to get Multiple Key Value in Dart Http

Please How Can I get this kind of API response in Flutter using http with FutureBuilder.
"GLODATA": {
"1000": {
"pname": "GLO 1.0GB/14days",
"price": "470",
"pld": "1000"
},
"1600.01": {
"pname": "GLO 2.0GB/30days",
"price": "940",
"pld": "1600.01"
},
"3750.01": {
"pname": "GLO 4.5GB/30days",
"price": "1900",
"pld": "3750.01"
},
"5000.01": {
"pname": "GLO 7.2GB/30days",
"price": "2430",
"pld": "5000.01"
}
},
I think in your case, you will need to do something like this:
Api:
Future<http.Response> getData() async {
final _api = "http://yourendpointhere";
http.Response response = await http.get(_api);
if (response.statusCode != 200) {
throw Exception("Request failed...");
}
return response;
}
Then consume your api:
http.Response response = await _apiInstance.getData();
if (response.body != null && response.body.isNotEmpty) {
String source = Utf8Decoder().convert(response.bodyBytes);
Map<String, Map<String, dynamic>> data = Map();
data = Map<String, Map<String, dynamic>>.from(json.decode(source));
}
After that, you can create a factory constructor in your model class, receiving that map and turning it into an instance of your class.

Interactive button doesn't work properly when using pub/sub

I'm writing a Hangouts Chat bot in C# that uses pub/sub so I can host the bot on our side of a firewall. Everything seems to work well except interactive buttons within cards. If I create a button with a specific action method name, the bot does receive the CARD_CLICKED message with the appropriate action method name. However, it doesn't seem like the card in the Hangouts Chat app knows a response was sent because the bot ends up getting the CARD_CLICKED message three times before the Hangouts Chat app finally says "Unable to contact Bot. Try again later". I've been using the Google.Apis.HangoutsChat.v1 and Google.Cloud.PubSub.V1 packages from NuGet for the bot.
This is speculation, but it seems like the issue might be that interactive buttons don't work properly through pub/sub. Any help would be appreciated.
Here is a snippet of the code I have:
SubscriptionName subscriptionName = new SubscriptionName(PROJECT_ID, SUBSCRIPTION_ID);
SubscriberServiceApiClient client = SubscriberServiceApiClient.Create();
GoogleCredential credential = GoogleCredential.FromFile(CREDENTIALS_PATH_ENV_PROPERTY).CreateScoped(HANGOUTS_CHAT_API_SCOPE);
HangoutsChatService chatService = new HangoutsChatService(new BaseClientService.Initializer
{
ApplicationName = "My Bot",
HttpClientInitializer = credential
});
while (true)
{
PullResponse response = client.Pull(subscriptionName, false, 3, CallSettings.FromCallTiming(CallTiming.FromExpiration(Expiration.FromTimeout(TimeSpan.FromSeconds(90)))));
if ((response.ReceivedMessages == null) || (response.ReceivedMessages.Count == 0))
Console.WriteLine("Pulled no messages.");
else
{
foreach (ReceivedMessage message in response.ReceivedMessages)
{
try
{
byte[] jsonBytes = message.Message.Data.ToByteArray();
JObject json = JObject.Parse(Encoding.UTF8.GetString(jsonBytes));
string messageType = (string)json["type"];
switch (messageType)
{
case "MESSAGE":
{
// Get text
string messageText = (string)json["message"]["text"];
Console.WriteLine($"[{messageType}] {messageText}");
// Send response
string spaceName = (string)json["space"]["name"];
SpacesResource.MessagesResource.CreateRequest request = chatService.Spaces.Messages.Create(new Message
{
Cards = new[]
{
new Card
{
Header = new CardHeader
{
Title = "Message Received!"
},
Sections = new[]
{
new Section
{
Widgets = new[]
{
new WidgetMarkup
{
Buttons = new[]
{
new Button
{
TextButton = new TextButton
{
Text = "Click Me!",
OnClick = new OnClick
{
Action = new FormAction
{
ActionMethodName = "ClickedAction"
}
}
}
}
}
}
}
}
}
}
},
Thread = new Thread
{
Name = (string)json["message"]["thread"]["name"]
}
}, spaceName);
Message responseMsg = request.Execute();
break;
}
case "CARD_CLICKED":
{
string actionMethodName = (string)json["action"]["actionMethodName"];
Console.WriteLine($"[{messageType}] {actionMethodName} at {((DateTime)json["message"]["createTime"]).ToString()}");
// Send response
string spaceName = (string)json["space"]["name"];
SpacesResource.MessagesResource.CreateRequest request = chatService.Spaces.Messages.Create(new Message
{
ActionResponse = new ActionResponse
{
Type = "UPDATE_MESSAGE"
},
Text = $"You clicked on '{actionMethodName}'.",
Thread = new Thread
{
Name = (string)json["message"]["thread"]["name"]
}
}, spaceName);
Message responseMsg = request.Execute();
break;
}
default:
{
Console.WriteLine($"[{messageType}]");
break;
}
}
}
catch (Exception ex)
{
Console.WriteLine($"Error parsing message: {ex}");
}
}
// Acknowledge the message so we don't see it again.
string[] ackIds = new string[response.ReceivedMessages.Count];
for (int i = 0; i < response.ReceivedMessages.Count; ++i)
ackIds[i] = response.ReceivedMessages[i].AckId;
client.Acknowledge(subscriptionName, ackIds);
}
}
Using buttons with Hangouts Chat API requires a custom answer including:
{
'thread': {
'name': thread_id
},
'actionResponse': {
'type': 'UPDATE_MESSAGE'
}
}
I'd recommend using Hangouts Chat API with a bot URL.

Change HTTP URL in Worklight adapter

I need to create an HTTP adapter for worklight but the url must be programmatically provided via a parameter.
1) I was able to pass the user/password but not the url. Is there a way to do that?
I also try to create my own java adapter to call the REST API, It works when I test the adapter but it seems my response is not in the expected format for worklight. I got this error:
2) BAD_PARAMETER_EXPECTED_DOCUMENT_OR_ARRAY_OF_DOCUMENT.
my Java adapter returns a JSONArtifact (JSONObject) but it seems that worklight want this to be embedded in another JSONObject such as { "array":{...}}.
Is there a way to convert a JSONObject to the format expected by worklight.
import org.apache.wink.json4j.JSON;
import org.apache.wink.json4j.JSONArtifact;
import org.apache.wink.json4j.JSONException;
private Header headerUserAgent = new Header("User-Agent", "Mozilla");
private Header headerAccept = new Header("Accept", "application/json");
private String hostName;
private String baseURL;
protected MyHttpClient(String userName, String userPassword, String hostName, String baseURL ) {
super();
Credentials defaultcreds = new UsernamePasswordCredentials(userName,
userPassword);
this.getState().setCredentials(AuthScope.ANY, defaultcreds);
this.hostName = hostName;
this.baseURL = baseURL;
}
private GetMethod getGetMethod(String url) throws URIException {
GetMethod httpMethod = new GetMethod(new HttpsURL("https://"+hostName+baseURL+url).getEscapedURI());
addCommonHeaders(httpMethod);
return httpMethod;
}
private JSONArtifact getResponseAsJSONObject(InputStream inputStream) throws IOException {
InputStreamReader reader = new InputStreamReader(inputStream);
try {
JSONArtifact json = JSON.parse(reader);
return json;
} catch (NullPointerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
Adapter:
function getResponse(user,password) {
var client = new com.itdove.mypackage.MyHttpClient(user,password,"myurl","mybaseurl");
return {
array : client.executeGet("mypath")
};
}
it works with this but this solution doesn't provide the service url as parameter:
function getResponseAdapters(path, username, password) {
var input = {
method : 'get',
returnedContentType : 'json',
headers: {
'User-Agent':'Mozilla',
'Authorization': 'Basic '+Base64.encode(username+':'+password),
} ,
path : '/resources/' + path
};
return WL.Server.invokeHttp(input);
}
function getResponse(username, password) {
return getMySCAWSAdapters(path, username, password);
}
Collection
vAPPArrayAdapterOptions = {
name: 'myResponseAdapter',
replace: '',
remove: '',
add: '',
load: {
procedure: 'getResponse',
params: ["user","password"],
key: 'array'
},
accept: function (data) {
return (data.status === 200);
}
},
...
vAPPArray = wlJsonStore.initCollection(
"vAPPArray",
vAPPArraySearchFields,
{adapter: vAPPArrayAdapterOptions,
onSuccess: initCollectionSuccessCallback,
onFailure: initCollectionFailureCallback,
load:true});
Many Thanks
Dominique
Found the solution:
First, I was using apache wink JSONArtifact instead of the com.ibm.json.java.JSONArtifact!
Secondly I modified my collector implement method as follow to add the status (not sure if it is needed or not)
function getResponse(user,password,hostname) {
var client = new com.itdove.mypackage.IWDHttpClient(user,password,hostname,"mypath");
return {
array :client.executeGet("mymethod"),
statusCode: client.getStatusCode(),
statusReason: client.getStatusReason()
};
}
in myCollector.js I set the user, password, hostname as follow before calling my initCollection.
params = [ settings.json.user, settings.json.password, settings.json.hostname ];
myAdapterOptions.load["params"] = params;