RPC call on bitcoind for adding P2SH - bitcoin

I have been searching around a lot and I can't seem to figure this out.
I want to create a transaction with a custom P2SH address by using Bitcoin Core's RPC calls. I found there is a redeemScript field in signrawtransaction so I'm assuming this is where I should send a hex encoding of my script. But this needs a txid, so should I first use createrawtransaction with the output being the address I want to send to and then sign the transaction with the script included?
I saw there is already a createmultisig call and since that is also P2SH it seems there should be something similar for other P2SH transactions.
Any idea how I can solve this or where I can find more information on this?

If I understand it correctly according to this section of the bitcoin book, you are supposed to create a hash out of your script and then convert this hash into an address which allows you to use the regular sendtoaddress rpc call to send coins to the address.
Another important part of the P2SH feature is the ability to encode a script hash as an address, as defined in BIP-13. P2SH addresses are Base58Check encodings of the 20-byte hash of a script, just like bitcoin addresses are Base58Check encodings of the 20-byte hash of a public key. P2SH addresses use the version prefix "5," which results in Base58Check-encoded addresses that start with a "3."
Now, Mohammed can give this "address" to his customers and they can use almost any bitcoin wallet to make a simple payment, as if it were a bitcoin address. The 3 prefix gives them a hint that this is a special type of address, one corresponding to a script instead of a public key, but otherwise it works in exactly the same way as a payment to a bitcoin address.
P2SH addresses hide all of the complexity, so that the person making a payment does not see the script.
Take a look at the whole section for how to convert the script to a hash.
You can download the executable that is used in the book here: https://github.com/libbitcoin/libbitcoin-explorer/releases

Related

How to get the transactions on BscScan by an address?

I am trying to get all the transactions by an address, because I want to get a specific transaction by the method (that occurs at a date time when a contract is created) and the an address. I know there is an API, but I can't find it.
For example, on this address https://bscscan.com/address/0xbe807dddb074639cd9fa61b47676c064fc50d62c I can see the methods of that address so I could go to the specific contract, but I can't get it by an API. Is it possible?
Would it be better to use a scraping?
You need use this free version - good way
https://bscscan.com/apis , then you can iterate every transaction.
Or do loop on all blocks and iterate every block - bad way.

Vies database split address

I'm using vatlayer API for getting company information by put in the vat number. https://vatlayer.com/documentation
Now I want split address info in the state, zipcode, addressline and address number.
I get the address info: BREDABAAN 13052900 SCHOTEN.
The address number and zipcode stands against each other without spacing. (1305number and 2900 zipcode).
Is there another API for working with the vies database where i can split these information? Or an work around for this bug?
VatLayer don't support the split atm.
I get the address information by:
$("#organisation_address_line_1").val(json.company_address);
Thanks in advance,
There's quite a lot of API's to handle VAT validation but the ones that provide information about the trader essentially all rely on the official API at http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl . It connects directly to the VIES system. Perhaps the values returned there are a bit different: it's worth trying your validation that way as well.
Unfortunately, since VIES does not return structured addresses (except for approximate matches, but only Spain supports them at the moment) and does not specify a common format for the free text addresses, you're going to have to deal with whatever format the country has chosen to provide, which means manual parsing.
I reckon 3rd party wrapping API's could handle guessing the format and splitting the formats on their own but I am not aware of any that would do it.

MessageBird originator handling

I am a bit confused conerning the services of the SMS Provider MessageBird; their API permits to include an "Originator", which is used as the sender of the SMS. On one hand, the documentation
https://developers.messagebird.com/
states that in some countries the originator is not used and refers to a list of country-specific information. On the other hand, this list
http://support.messagebird.com/hc/en-us/sections/202017565-Country-Info-Restrictions?page=1#articles
does not include an entry for Denmark. The specific problem is that using the same account, the originator is used for Germany, but apparently doesn't work for Denmark. Does anyone have any experience with this or any information which might be helpful? If so, I would appreciate any comment.
The originator as you said it is going to be used as the sender of the SMS.
But there are restrictions as you noted on the docs. For example when you are sending messages to the US you cannot use alphanumeric originators like "Codor LLC". You need to use a numeric phone number.
If you are trying to send an SMS to Denmark from a german originator number it should work. No restrictions apply here.
Something else can be broken. Please contact support (support#messagebird.com) and we'll help you out (I work at MessageBird).

Google maps geocoding returns empty string

Yesterday I created a new Google map geocoding API key on the developper console. I need to get gps coordinates from a server script. When I use the "which key do I need" in the console, it tells me I choosed the right key. I also allowed the fixed IP of my server in the key settings.
Now, when I use "https://maps.googleapis.com/maps/api/geocode/json?address=MY_ADDRESS&sensor=false&key=MY_KEY", it returns an empty string.
When I use "http//maps.googleapis.com/maps/api/geocode/json?address=MY_ADDRESS&sensor=false&key=MY_KEY" it returns a warning about this kind of queries must use https (which is consistent with the doc).
And finally, when I use "http//maps.googleapis.com/maps/api/geocode/json?address=MY_ADDRESS&sensor=false" (no https and no key) I get the relevant data, either in json or xml. As explained in the doc, this can be used with a limit of 2500 geocoding per day, but the problem is that I have different domains on the same server (with the same IP) that geocode, and since google tracks by IP to evaluate daily quotas...
So my question is : what am I missing when trying to geocode an address using https and the key ?
The only thing that crossed my mind is : do I need to activate billing in google maps, even though I know for sure that I will never exceed the free quota of 2500 queries per day, at least with the project to which the key is associated ?
Thanks in advance for any tip or advice.

get 9 digit zip code from 5 digit zip code, programmatic, api

I have 5 digit zip codes, these are retrieved from Google Maps Api.
My dilemma is that I have to connect to a remote database which also contains addresses. If the address does not exist in that database, I have to write it, if it does exist then I do nothing except store the ID that database has assigned to the address. The problem arises since the api to check this database does not take wildcards, the addresses in that database have 9 digit zip codes (5+4) and will not return that the rest of the address matches my address with 5 digit zip codes.
The remote system will tell me that the address does not exist with the ones I send it.
So to prevent duplicate addresses from being written to the database I would need to find the 9 digit version of the zip code I have before sending it.
How would this be done? Is there a formula for determining what the last 4 digits of a 5 digit address are? Does the USPS have an API? Does the Census have a giant table?
Insight appreciated
You are only allowed to use the USPS API for information if you are using the USPS to send out mail...
But you could check out SmartyStreets (I used to work there) or another CASS-Certified vendor. They are licensed for address verification, and you can also perform city-state and ZIP code lookups without an address (depending on who you choose).
I think you'll find them much easier and more comprehensive than the default USPS web service.
Here's some sample code... take your pick: https://github.com/smartystreets/LiveAddressSamples
The US Postal Service have a number of APIs. Their "Address Information APIs" include:
Address Standardization
Eliminate addressing errors and help ensure accurate and timely delivery. This tool corrects errors in street addresses, including abbreviations and missing information. It also supplies a ZIP+4® Code.
ZIP Code™ Lookup
Find matching ZIP Codes or ZIP+4 Codes for any given address, city, and state in the U.S.
City/State Lookup
Use a ZIP Code to get accurate city and state information.
The Address Information APIs require permission to use.