Has the Bitcoin getblocktemplate response json changed? Where is the coinbasetxn now? - rpc

When calling getblocktemplate for the bitcoin rpc, the json (dictionary) response that comes back no longer seems to have a 'coinbasetxn' key in it. Where is the coinbase transaction now?
Sample response to getblocktemplate():
{'height': 453825, 'mintime': 1487548277, 'version': 536870912,
'coinbasevalue': 1306788433, 'previousblockhash':
'0000000000000000019ca63484f8251b15647869d4c36ec5b201277f3e2aa70b',
'rules': ['csv'], 'sigoplimit': 20000, 'weightlimit': 4000000,
'mutable': ['time', 'transactions', 'prevblock'], 'target':
'0000000000000000027e93000000000000000000000000000000000000000000',
'bits': '18027e93', 'longpollid':
'0000000000000000019ca63484f8251b15647869d4c36ec5b201277f3e2aa70b20632',
'vbrequired': 0, 'noncerange': '00000000ffffffff', 'curtime':
1487550914, 'coinbaseaux': {'flags': ''}, 'transactions': [{'depends':
[], 'data':
'0100000001fb5b6947704577fd09260adf7f80c92ada4776ca7674a5fb8af40df3c747293a010000006a473044022048aab0d8bd6c127696ce2cceb42693af2ae8eec561a33acf43577193070cd965022043667ae3c25661d251133b75fbefa8b9b5d3dddeedae028c90899c642f693479012103c7b4ed6b91df7eb7d2bd62a6257dd2e2fa79d07e81080b7e95bcd3d9e448f464feffffff02504b4500000000001976a914fd09ed8b3099ee1f67693c3c6c25ca7ecb150fcf88ac48c5374e000000001976a914a97d5d95cd416dc0f734cb028f0785a4f545cea988ac96ec0600',
'txid':
'2ed056bed0417623433d6b600dfb6afcebb8c22b1f42b6e776cf8263289fb5ac',
'sigops': 2, 'weight': 900, 'fee': 204345, 'hash':
'2ed056bed0417623433d6b600dfb6afcebb8c22b1f42b6e776cf8263289fb5ac'},
{'depends': [], 'data':
'01000000011e7d9c88fe30a4c9fa1ec229e7c11704ec0185e36...... (...rest of
transactions...)

bitcoin core doesn't provide a coinbasetxn in the block template; it's the pool software that does that. if you're coding mining software to connect directly to bitcoind without using a pool, you'll need to generate the coinbase transaction yourself.

Confirmed that it is the first transaction of the transaction list. Can close this question (no longer need help). Thank you.

Related

Woocommerce Api Total Spent Column not populating

Hi I am creating order from other platform to wordpress. The customers that were subscribed offline but need to be put on woocommerce. but it is not full filling one thing in the column automatically.
The first row is created with api. it shows me the total amount of the order but i cannot find how will this field be populated. my code for created new order
billing_info = {
'first_name': row.firstName,
'last_name': row.lastName,
'email': row.email,
}
line_items = []
line_items.append(
{
'product_id': businessCreditProductId,
'quantity': 1,
'subtotal': row.amount,
'total': row.amount,
'price': float(row.amount),
})
wcapi.post('orders', data={
'customer_id': userId,
'line_items': line_items,
'status': 'completed',
'billing': billing_info,
})

Steam Store API question about getting response meant for USA instead of Canada

I am hosting a Discord Bot on a server in Canada. When I do
let response = await fetch("http://store.steampowered.com/api/appdetails?appids=251570")
I get a response with the price_overview information in CAD. I would like it in USD because I am located in the US. Is there anyway to get the USD response instead of the CAD response? (preferably without just doing the math to convert CAD to USD)
You can append &cc=us&l=en to the URL to get the price in USD:
https://store.steampowered.com/api/appdetails?appids=251570&cc=us&l=en
which yields:
price_overview: {
currency: "USD",
initial: 2499,
final: 2499,
discount_percent: 0,
initial_formatted: "",
final_formatted: "$24.99"
},
So in your code:
let response = await fetch("https://store.steampowered.com/api/appdetails?appids=251570&cc=us&l=en")
Note: This is an unofficial API and could change anytime.

How to view [Circular] in Node?

In my console, I'm getting:
{
'a': [Circular],
'b': [Circular],
'c': [Circular]
}
How can I see the contents of [Circular]? I've tried console.log(), util.inspect() and console.dir() and I'm still getting [Circular] instead of the actual content.
Edit:
I'm trying to see the actual content, how many layers deep it goes, etc., for debugging purposes. Linked question does not address any of that.
Basically that's recursion, as far as I know there is no way to possibly log a [Circular] reference (don't quote me on that), but if you could it would probably be like this:
{
'a': {
'a': {
'a':{
// never ending
}
}
}
}

DynamoDB Pagination via Boto3, NextToken is not present but LastEvaluatedKey is?

The documentation for boto3 and dynamodb paginators specify that NextToken should be returned when paging, and you would then include that token in the next query for StartingToken to resume a paging session (as would happen when accessing information via a RESTful API).
However, my testing shows that it doesn't return NextToken in the results, but rather LastEvaluatedKey. I was thinking I could use LastEvaluatedKey as the token, but that doesn't work?
paginator = client.get_paginator('scan')
page_iterator = paginator.paginate(TableName='test1', PaginationConfig={'PageSize': 1 , 'MaxItems': 5000, 'MaxSize': 1 })
for page in page_iterator:
print(page)
break
I would expect the page object returned from the page_iterator to include NextToken Key but it does not?
{'Items': [{'PK': {'S': '99'}, 'SK': {'S': '99'}, 'data': {'S': 'Test Item 99'}}], 'Count': 1, 'ScannedCount': 1, 'LastEvaluatedKey': {'PK': {'S': '99'}, 'SK': {'S': '99'}}, 'ResponseMetadata': {'RequestId': 'DUE559L8KVKVH8H7G0G2JH0LUNVV4KQNSO5AEMVJF66Q9ASUAAJG', 'HTTPStatusCode': 200, 'HTTPHeaders': {'server': 'Server', 'date': 'Mon, 27 May 2019 14:22:09 GMT', 'content-type': 'application/x-amz-json-1.0', 'content-length': '153', 'connection': 'keep-alive', 'x-amzn-requestid': 'DUE559L8KVKVH8H7G0G2JH0LUNVV4KQNSO5AEMVJF66Q9ASUAAJG', 'x-amz-crc32': '3759060959'}, 'RetryAttempts': 0}}
What am I missing?
UPDATE: Somehow related to this? How to use Boto3 pagination
There are a few ways to address this using the boto3 scan paginator.
The first option is to call build_full_result like so:
result = paginator.paginate(TableName="your_table", PaginationConfig={"MaxItems":10, "PageSize": 10}).build_full_result()
That returns a response with 10 items, and 'NextToken' is populated provided there are more than 10 items. This is probably the simplest way, you can just treat the MaxItems as your returned page size and if 'NextToken' is empty you are at the end of the scan.
I noticed if you don't specify a page size the results are the same, but the consumed capacity and 'ScannedCount' are higher.
Another way is to do the encoding of the 'StartingToken' using the TokenEncoder in botocore.paginate directly.
If the initial call to the paginator is like:
pagination_config = {
"MaxItems": 5000,
"PageSize": 10,
}
scan_iterator = scan_paginator.paginate(
TableName="your_table_name",
PaginationConfig=pagination_config
)
The paged results will be as the question describes. The first 10 results will be returned in the first page, and 'NextToken' isn't specified but 'LastEvaluatedKey' is.
To use it, encode the returned 'LastEvaluatedKey' as the 'ExclusiveStartKey' and pass that into as the 'StartingToken' in the pagination config.
from botocore.paginate import TokenEncoder
encoder = TokenEncoder()
for page in scan_iterator:
if "LastEvaluatedKey" in page:
encoded_token = encoder.encode({"ExclusiveStartKey": page["LastEvaluatedKey"]})
Then:
pagination_config = {
"MaxItems": 500,
"PageSize": 10,
"StartingToken": encoded_token
}
The reason to encode the primary key as the 'ExclusiveStartKey' is that it's what the actual scan API expects. Essentially the paginators are encoding / decoding the 'LastEvaluatedKey' and 'ExclusiveStartKey' into the 'NextToken' and 'StartingToken' values. If you do a base64 decode of the 'NextToken' returned when doing build_full_result you'll see that it is also uses the 'ExclusiveStartKey'.

eBay Fulfillment API for Get Orders

I have tried getOrders of Trading API but it doesn't return all orders like cancelled, shipped etc. I have tried to hit Get Orders of Fulfillment API in ebay to get all the orders.
HTTP.call('GET','https://api.ebay.com/sell/fulfillment/v1/order',
{
{Headers: {Authorization: Bearer<AccessToken>}
}
});
Output is
{
"href": "https://api.ebay.com/sell/fulfillment/v1/order?filter=creationdate:%5B2016-08-16T12:53:34.299Z..%5D&limit=50&offset=0",
"total": 0,
"limit": 50,
"offset": 0,
"orders": []
}
It doesn't return any orders.
Anyone knows then please tell me.
The returned output has a filter on it:
filter=creationdate:%5B2016-08-16T12:53:34.299Z..%5D
So this is likely to be your problem - you probably need to specify a date range to override this.

Resources