Doubled Nov 4th label in visualization - keen-io

I just find there exist two data records with labeled date "Nov 4th" on the chart though I got the right data.
See Screenshot
Here is the code I wrote:
new Keen.Dataviz()
.el('#actionChart')
.title(' ')
.chartOptions({
axis: {
y: {
label: {
text: 'Count',
position: 'outer-middle'
},
min: 0,
padding: { bottom: 0 }
},
}
})
.height(300)
.colorMapping({
Presented: ANALYTICS_COLORS[1],
Facebook: ANALYTICS_COLORS[3],
SMS: ANALYTICS_COLORS[2]
})
.type('line')
.stacked(false)
.prepare();
});
and the data I got:
{"result": [{"value": [{"action": "presented", "result": 1661}, {"action": "selected_facebook", "result": 21}], "timeframe": {"start": "2018-11-01T07:00:00.000Z", "end": "2018-11-02T07:00:00.000Z"}}, {"value": [{"action": "presented", "result": 1398}, {"action": "selected_facebook", "result": 9}], "timeframe": {"start": "2018-11-02T07:00:00.000Z", "end": "2018-11-03T07:00:00.000Z"}}, {"value": [{"action": "presented", "result": 1718}, {"action": "selected_facebook", "result": 17}], "timeframe": {"start": "2018-11-03T07:00:00.000Z", "end": "2018-11-04T07:00:00.000Z"}}, {"value": [{"action": "presented", "result": 1498}, {"action": "selected_facebook", "result": 16}], "timeframe": {"start": "2018-11-04T07:00:00.000Z", "end": "2018-11-05T07:00:00.000Z"}}, {"value": [{"action": "presented", "result": 1330}, {"action": "selected_facebook", "result": 10}], "timeframe": {"start": "2018-11-05T07:00:00.000Z", "end": "2018-11-06T07:00:00.000Z"}}, {"value": [{"action": "presented", "result": 1351}, {"action": "selected_facebook", "result": 20}], "timeframe": {"start": "2018-11-06T07:00:00.000Z", "end": "2018-11-07T07:00:00.000Z"}}, {"value": [{"action": "presented", "result": 1819}, {"action": "selected_facebook", "result": 12}], "timeframe": {"start": "2018-11-07T07:00:00.000Z", "end": "2018-11-08T07:00:00.000Z"}}]}
I tried the latest .js file, and same problem happens
also, add
axis: {
x: {
localtime: false
}
},
does not work, see here

Find the reason from .call(function(){console.log(this.dataset);}):
the timezone is different. Before it's GMT-7, the last three

it's probably related to c3 local timezone conversion.
https://github.com/keen/keen-dataviz.js#date-format
To turn off the conversion use the code below:
const chart = new KeenDataviz({
container: '#some_container', // required
axis: {
x: {
localtime: false
}
}
});

Related

Is it correct to see a different cabin value aside that passed in the get FlightOffers APi as travelerClass?

From the documentation of the Get Route for the flight offers Api, I can add travelerClass as a filter to make a request. If I add say travelerClass as ECONOMY?
I expect to see only offers with ECONOMY. However I see that within the fareDetailsBySegment section in the result, I see that some Offers have their cabin values as other than ECONOMY. I see some with value of BUSINESS while others as PREMIUM_ECONOMY.
Is this proper?
My Concern
I want to be able to get all bookings that where ECONOMY based only. So I need to be sure that the flight offers returned in the first place are strictly limited by the travelerClass.
I will appreciate any clarity on the this issue. Also if there is a better way to go about this concern above, it will be most appreciated.
An example of my request is below:
Amadeus.shopping.flightOffersSearch.get({
originLocationCode: 'SYD',
destinationLocationCode: 'BKK',
departureDate: '2022-11-01',
adults: '1',
travelClass: 'ECONOMY'
}).then(...)
Offer with BUSINESS instead of ECONOMY
{
"type": "flight-offer",
"id": "22",
"source": "GDS",
"instantTicketingRequired": false,
"nonHomogeneous": false,
"oneWay": false,
"lastTicketingDate": "2022-11-01",
"numberOfBookableSeats": 6,
"itineraries": [
{
"duration": "PT28H20M",
"segments": [
{
"departure": {
"iataCode": "SYD",
"terminal": "1",
"at": "2022-11-01T12:00:00"
},
"arrival": {
"iataCode": "PVG",
"terminal": "2",
"at": "2022-11-01T19:30:00"
},
"carrierCode": "MU",
"number": "562",
"aircraft": {
"code": "77W"
},
"operating": {
"carrierCode": "MU"
},
"duration": "PT10H30M",
"id": "13",
"numberOfStops": 0,
"blacklistedInEU": false
},
{
"departure": {
"iataCode": "PVG",
"terminal": "1",
"at": "2022-11-02T08:45:00"
},
"arrival": {
"iataCode": "BKK",
"at": "2022-11-02T12:20:00"
},
"carrierCode": "MU",
"number": "541",
"aircraft": {
"code": "320"
},
"operating": {
"carrierCode": "MU"
},
"duration": "PT4H35M",
"id": "14",
"numberOfStops": 0,
"blacklistedInEU": false
}
]
}
],
"price": {
"currency": "EUR",
"total": "4048.84",
"base": "3858.00",
"fees": [
{
"amount": "0.00",
"type": "SUPPLIER"
},
{
"amount": "0.00",
"type": "TICKETING"
}
],
"grandTotal": "4048.84"
},
"pricingOptions": {
"fareType": [
"PUBLISHED"
],
"includedCheckedBagsOnly": true
},
"validatingAirlineCodes": [
"MU"
],
"travelerPricings": [
{
"travelerId": "1",
"fareOption": "STANDARD",
"travelerType": "ADULT",
"price": {
"currency": "EUR",
"total": "4048.84",
"base": "3858.00"
},
"fareDetailsBySegment": [
{
"segmentId": "13",
"cabin": "ECONOMY",
"fareBasis": "YSE0WDNQ",
"class": "Y",
"includedCheckedBags": {
"quantity": 2
}
},
{
"segmentId": "14",
"cabin": "BUSINESS",
"fareBasis": "QSE0WCNL",
"class": "Q",
"includedCheckedBags": {
"quantity": 2
}
}
]
}
]
}
in order to apply the filter for cabin class, I suggest you to try with POST method.
in POST method has more search criteria you can apply, below example is something that I have tried and it works: response only contains ECONOMY classes by updating values under cabinRestrictions.
details of the request model is available in API reference page
amadeus.shopping.flightOffersSearch.post(JSON.stringify({
"currencyCode": "USD",
"originDestinations": [
{
"id": "1",
"originLocationCode": "SYD",
"destinationLocationCode": "BKK",
"departureDateTimeRange": {
"date": "2022-11-01"
}
}
],
"travelers": [
{
"id": "1",
"travelerType": "ADULT"
}
],
"sources": [
"GDS"
],
"searchCriteria": {
"maxFlightOffers": 10,
"flightFilters": {
"cabinRestrictions": [
{
"cabin": "ECONOMY",
"coverage": "ALL_SEGMENTS",
"originDestinationIds": [
1
]
}
]
}
}
})).then(...)

Sequelize distinct in include throws syntax error at or near \"DISTINCT\"

I am trying to filter out the duplicated row after performing an include
My code
const courses = await Course.findAll({
subQuery: false,
order: [ [ 'courseID', 'ASC' ] ],
include: [
{
model: CourseAvailable,
as: 'courseAvailable',
required: false
}
]
});
Output
{
"success": true,
"data": [
{
"id": 132,
"courseID": "CSS112",
"courseName": "COMPUTER PROGRAMMING",
"required": null,
"createdAt": "2020-05-21T07:29:58.596Z",
"updatedAt": "2020-05-21T07:29:58.596Z",
"courseAvailable": [
{
"id": 508,
"courseID": "CSS112",
"semester": 2,
"credit": 3,
"totalSeat": 55,
"section": "1",
"allowedGroup": "CSS 1 A(0)",
"day": "อ.",
"start": "08.30",
"end": "10.30",
"classroom": "SCL607",
"createdAt": "2020-05-21T07:30:10.417Z",
"updatedAt": "2020-05-21T07:30:10.417Z"
},
{
"id": 509,
"courseID": "CSS112",
"semester": 2,
"credit": 3,
"totalSeat": 55,
"section": "1",
"allowedGroup": "OTHER (0)",
"day": "อ.",
"start": "08.30",
"end": "10.30",
"classroom": "SCL607",
"createdAt": "2020-05-21T07:30:10.417Z",
"updatedAt": "2020-05-21T07:30:10.417Z"
},
{
"id": 510,
"courseID": "CSS112",
"semester": 2,
"credit": 3,
"totalSeat": 55,
"section": "1",
"allowedGroup": "OTHER (0)",
"day": "อ.",
"start": "10.30",
"end": "12.30",
"classroom": "SCL703",
"createdAt": "2020-05-21T07:30:10.417Z",
"updatedAt": "2020-05-21T07:30:10.417Z"
}
]
}
]
}
As you can see in the courseAvailable it returned 3 elements, And I wanted to do the distinction by distinct the element if the (section,start,end) are the same
so this is my expected output
{
"success": true,
"data": [
{
"id": 132,
"courseID": "CSS112",
"courseName": "COMPUTER PROGRAMMING",
"required": null,
"createdAt": "2020-05-21T07:29:58.596Z",
"updatedAt": "2020-05-21T07:29:58.596Z",
"courseAvailable": [
{
"id": 508,
"courseID": "CSS112",
"semester": 2,
"credit": 3,
"totalSeat": 55,
"section": "1",
"allowedGroup": "CSS 1 A(0)",
"day": "อ.",
"start": "08.30",
"end": "10.30",
"classroom": "SCL607",
"createdAt": "2020-05-21T07:30:10.417Z",
"updatedAt": "2020-05-21T07:30:10.417Z"
},
{
"id": 510,
"courseID": "CSS112",
"semester": 2,
"credit": 3,
"totalSeat": 55,
"section": "1",
"allowedGroup": "OTHER (0)",
"day": "อ.",
"start": "10.30",
"end": "12.30",
"classroom": "SCL703",
"createdAt": "2020-05-21T07:30:10.417Z",
"updatedAt": "2020-05-21T07:30:10.417Z"
}
]
}
]
}
(MY EXPECTATION) You can see that the id 509 is disappeared because the (section,start,end) have been queried by the distinct
What I've tried
const courses = await Course.findAll({
subQuery: false,
order: [ [ 'courseID', 'ASC' ] ],
include: [
{
model: CourseAvailable,
as: 'courseAvailable',
attributes: [ [ sequelize.fn('DISTINCT', sequelize.col('section')), 'section' ] ].concat(
Object.keys(CourseAvailable.rawAttributes)
), // was trying to do distinct only one column for checking if the distinct working or not working at all, and I am not sure if this is the right way to do it also, after I've been researching it for a day but found nothings that will solves my problem
required: false
}
]
});
But it threw me an error => syntax error at or near \"DISTINCT\".
I also tried using sequelize.literal to do the distinct as well but the error still the same

Raw transaction Error: mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)

I'm trying to create and sign a raw transaction and broadcast it to the testnet.
This is input transaction:
{
"error": null,
"id": "1",
"result": {
"blockhash": "000000000000006ad3b6dcf2a1e1725eeb3f7c5e424feca4577d4c9e106d26e5",
"blocktime": 1587495286,
"confirmations": 689,
"hash": "c6cbe3462b78a072ef0ff3f0b436372ad55d811b4ba0feb581d0adfefdd8f815",
"hex": "02000000000101fd1819b6a5f2ca631fd7eafecdb021cb1e2ea28485cc72b8903967637d784aa40100000017160014030df68f3c20d14bd8e998588ca7e640ada02284feffffff0296361b00000000001976a914814a2c0bb0d155667341be55633e7351a7d5c57888acde1745290100000017a9149c5fefdc8021652844976aa2ba3e49f0933933c887024730440220033b4acb8120f25db5c83fb8ed4d73dc1e4d45e271c98d9f8ac46f2cc6de32e502200405228466f0b07ae8edc7d80d81c6c2983c811ee6d4588bf46ce65fdf000bc80121039657df486ea7bf33580ce678a2ac90b0dc2b82e97edc23d36daf1743d618d355ca421a00",
"locktime": 1721034,
"size": 249,
"time": 1587495286,
"txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",
"version": 2,
"vin": [
{
"scriptSig": {
"asm": "0014030df68f3c20d14bd8e998588ca7e640ada02284",
"hex": "160014030df68f3c20d14bd8e998588ca7e640ada02284"
},
"sequence": 4294967294,
"txid": "a44a787d63673990b872cc8584a22e1ecb21b0cdfeead71f63caf2a5b61918fd",
"txinwitness": [
"30440220033b4acb8120f25db5c83fb8ed4d73dc1e4d45e271c98d9f8ac46f2cc6de32e502200405228466f0b07ae8edc7d80d81c6c2983c811ee6d4588bf46ce65fdf000bc801",
"039657df486ea7bf33580ce678a2ac90b0dc2b82e97edc23d36daf1743d618d355"
],
"vout": 1
}
],
"vout": [
{
"n": 0,
"scriptPubKey": {
"addresses": [
"msJaKN7KCGARZrKWyy169GzztFLx7aTRBf"
],
"asm": "OP_DUP OP_HASH160 814a2c0bb0d155667341be55633e7351a7d5c578 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914814a2c0bb0d155667341be55633e7351a7d5c57888ac",
"reqSigs": 1,
"type": "pubkeyhash"
},
"value": 0.01783446
},
{
"n": 1,
"scriptPubKey": {
"addresses": [
"2N7W4L2UTnsTW4wYVLgBGLKoxHdFJ9L54WU"
],
"asm": "OP_HASH160 9c5fefdc8021652844976aa2ba3e49f0933933c8 OP_EQUAL",
"hex": "a9149c5fefdc8021652844976aa2ba3e49f0933933c887",
"reqSigs": 1,
"type": "scripthash"
},
"value": 49.87361246
}
],
"vsize": 168,
"weight": 669
}
}
I do the following steps:
Create the raw transaction. This is the serialized raw transaction:
0100000001dcabee1e490bc90c9b4d739baba71f6f060c0281d0f4a41f9d0dad67546cd3cc0000000000ffffffff0196361b00000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac00000000
Decode the raw transaction. This is the decoded transaction:
{
"error": null,
"id": "1",
"result": {
"hash": "787a2c60c4bd1d92590e6dfe132f18322c27a2667f134903393de0e6f973234a",
"locktime": 0,
"size": 85,
"txid": "787a2c60c4bd1d92590e6dfe132f18322c27a2667f134903393de0e6f973234a",
"version": 1,
"vin": [
{
"scriptSig": {
"asm": "",
"hex": ""
},
"sequence": 4294967295,
"txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",
"vout": 0
}
],
"vout": [
{
"n": 0,
"scriptPubKey": {
"addresses": [
"moinqaiuWShfsemB9nGcAGFZNMa3ZwPMq6"
],
"asm": "OP_DUP OP_HASH160 59fe1a9f9f0a5af33396c59990f064be1ca51274 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac",
"reqSigs": 1,
"type": "pubkeyhash"
},
"value": 0.01783446
}
],
"vsize": 85,
"weight": 340
}
}
Sign the raw transaction. I don't have access to the private keys, because they are stored in a HSM. To sign the transaction, I have to send the serialized transaction and the public key to the HSM endpoint. It signs the transaction with the private key, which belongs to the public key and returns the signature.
The signature looks like this:
3045022100f1f05b567ff95997c60c6ece7b78df1b3ed12d145551e41986a682b807f9adaf02201c914c74297b28a9564b17fd1e94710ed2ad0c32147b26e44e71fefdce51df9a
This is the public key:
3056301006072a8648ce3d020106052b8104000a034200045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992
Decode the singed transaction. This is the decoded signed transaction:
{
"error": null,
"id": "1",
"result": {
"hash": "6d97a4e3239b375121b189ebb56af72c7f4111a03f1796e2ced241afe97d733a",
"locktime": 0,
"size": 224,
"txid": "6d97a4e3239b375121b189ebb56af72c7f4111a03f1796e2ced241afe97d733a",
"version": 1,
"vin": [
{
"scriptSig": {
"asm": "3045022100f1f05b567ff95997c60c6ece7b78df1b3ed12d145551e41986a682b807f9adaf02201c914c74297b28a9564b17fd1e94710ed2ad0c32147b26e44e71fefdce51df9a[ALL] 045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992",
"hex": "483045022100f1f05b567ff95997c60c6ece7b78df1b3ed12d145551e41986a682b807f9adaf02201c914c74297b28a9564b17fd1e94710ed2ad0c32147b26e44e71fefdce51df9a0141045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992"
},
"sequence": 4294967295,
"txid": "ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc",
"vout": 0
}
],
"vout": [
{
"n": 0,
"scriptPubKey": {
"addresses": [
"moinqaiuWShfsemB9nGcAGFZNMa3ZwPMq6"
],
"asm": "OP_DUP OP_HASH160 59fe1a9f9f0a5af33396c59990f064be1ca51274 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac",
"reqSigs": 1,
"type": "pubkeyhash"
},
"value": 0.01763446
}
],
"vsize": 224,
"weight": 896
}
}
Broadcast the signed transaction with RPC sendrawtransaction:
{"id":"1","jsonrpc":"1.0","method":"sendrawtransaction","params":["0100000001dcabee1e490bc90c9b4d739baba71f6f060c0281d0f4a41f9d0dad67546cd3cc000000008b483045022100f1f05b567ff95997c60c6ece7b78df1b3ed12d145551e41986a682b807f9adaf02201c914c74297b28a9564b17fd1e94710ed2ad0c32147b26e44e71fefdce51df9a0141045ca49382a5836bc13732efb3e66c5fd4ed159679517b7fdc48796e5b411af09f08d3a7b663610006f972162bd0f8f77a140782401f87b2f34f330777e59fb992ffffffff0176e81a00000000001976a91459fe1a9f9f0a5af33396c59990f064be1ca5127488ac00000000"]}
I always get the following error:
{
"error": {
"code": -26,
"message": "mandatory-script-verify-flag-failed (Signature must be zero for failed CHECK(MULTI)SIG operation)"
},
"id": "1",
"result": null
}
I also tried to broadcast it on https://live.blockcypher.com/btc/pushtx. There I get the following error:
Error validating transaction: Error running script for input 0 referencing ccd36c5467ad0d9d1fa4f4d081020c066f1fa7ab9b734d9b0cc90b491eeeabdc at 0: Script was NOT verified successfully..
What is wrong with my transaction?

Brushing/linking in vega (not vega-lite)

I'm trying to brush/link two plots in vega, more specifically a node-link diagram and a couple of scatterplots. Based on how dragging works with signals in the node-link diagram I did get quite far, but not far enough...
For the sake of simplicity, I'll provide a little test code here using just two scatterplots:
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"padding": 0,
"autosize": "none",
"width": 800,
"height": 400,
"signals": [
{ "description": "Any datapoint is activated",
"name": "datapoint_is_activated", "value": false,
"on": [
{
"events": "symbol:mouseover",
"update": "true"
},
{
"events": "symbol:mouseout",
"update": "false"
}
]
},
{ "description": "Active datapoint",
"name": "activated_datapoint", "value": null,
"on": [
{
"events": "symbol:mouseover",
"update": "item()"
},
{
"events": "symbol:mouseout",
"update": "null"
}
]
}
],
"data": [
{
"name": "table",
"values": [
{"name": "point A", "a": 1, "b": 2, "c": 3},
{"name": "point B", "a": 4, "b": 5, "c": 6},
{"name": "point C", "a": 9, "b": 8, "c": 7}
]
}
],
"scales": [
{ "name": "xscale",
"type": "linear",
"domain": [0,10],
"range": [0,200]
},
{ "name": "yscale",
"type": "linear",
"domain": [0,10],
"range": [0,200]
}
],
"layout": {"padding": 20},
"marks": [
{ "name": "plot1",
"type": "group",
"axes": [
{"orient": "bottom", "scale": "xscale"},
{"orient": "right", "scale": "yscale"}
],
"marks": [
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"field": "a", "scale": "xscale"},
"y": {"field": "b", "scale": "yscale"},
"tooltip": {"field": "name"}
},
"update": {
"size": {"value": 100},
"fill": {"value": "grey"}
}
}
}
]
},
{ "name": "plot2",
"type": "group",
"axes": [
{"orient": "bottom", "scale": "xscale"},
{"orient": "right", "scale": "yscale"}
],
"marks": [
{
"type": "symbol",
"from": {"data": "table"},
"on": [
{
"trigger": "datapoint_is_activated",
"modify": "activated_datapoint",
"values": "{fill: \"red\"}"
},
{
"trigger": "!datapoint_is_activated",
"modify": "activated_datapoint",
"values": "{fill: \"grey\"}"
}
],
"encode": {
"enter": {
"x": {"field": "a", "scale": "xscale"},
"y": {"field": "c", "scale": "yscale"},
"size": {"value": 100},
"tooltip": {"field": "name"}
},
"update": {
"fill": {"value": "grey"}
}
}
}
]
}
]
}
The resulting image looks like this:
The idea is that hovering over a datapoint in the left plot will highlight the corresponding datapoint in the right plot. I know this is straightforward in vega-lite, but that does not (yet) support node-link diagrams. Hence: vega.
My approach in the code is to:
create a signal in the outer scope that tracks (a) if there is a point activated, and (b) which point this is
in plot 2 to have a trigger that takes the activated datapoint and changes its colour to 'red'.
I have an inkling feeling that it has to do with my definition of the modify and values part, but I can't figure it out.
Any help very much appreciated!
Thank you,
jan.
After a lot of trial and error, I did find a way to do this. Instead of using a trigger (which I believe would be the canonical way of doing this), I merely use a test in the fill section: datapoint_is_activated && datum === activated_datapoint.datum. See code and image below.
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"padding": 0,
"autosize": "none",
"width": 800,
"height": 400,
"signals": [
{ "description": "Any datapoint is activated",
"name": "datapoint_is_activated", "value": false,
"on": [
{
"events": "symbol:mouseover",
"update": "true"
},
{
"events": "symbol:mouseout",
"update": "false"
}
]
},
{ "description": "Active datapoint",
"name": "activated_datapoint", "value": null,
"on": [
{
"events": "symbol:mouseover",
"update": "item()"
},
{
"events": "symbol:mouseout",
"update": "null"
}
]
}
],
"data": [
{
"name": "table",
"values": [
{"name": "point A", "a": 2, "b": 2, "c": 4},
{"name": "point B", "a": 4, "b": 5, "c": 6},
{"name": "point C", "a": 5, "b": 3, "c": 5}
]
}
],
"scales": [
{ "name": "xscale",
"type": "linear",
"domain": [0,10],
"range": [0,200]
},
{ "name": "yscale",
"type": "linear",
"domain": [0,10],
"range": [0,200]
}
],
"layout": {"padding": 20},
"marks": [
{ "name": "plot1",
"type": "group",
"axes": [
{"orient": "bottom", "scale": "xscale"},
{"orient": "right", "scale": "yscale"}
],
"marks": [
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"field": "a", "scale": "xscale"},
"y": {"field": "b", "scale": "yscale"},
"tooltip": {"field": "name"},
"size": {"value": 200}
},
"update": {
"fill": [
{"test": "datapoint_is_activated && datum === activated_datapoint.datum",
"value": "red"},
{"value": "lightgrey"}
]
}
}
}
]
},
{ "name": "plot2",
"type": "group",
"axes": [
{"orient": "bottom", "scale": "xscale"},
{"orient": "right", "scale": "yscale"}
],
"marks": [
{
"type": "symbol",
"from": {"data": "table"},
"encode": {
"enter": {
"x": {"field": "a", "scale": "xscale"},
"y": {"field": "c", "scale": "yscale"},
"size": {"value": 200},
"tooltip": {"field": "name"}
},
"update": {
"fill": [
{"test": "datapoint_is_activated && datum === activated_datapoint.datum",
"value": "red"},
{"value": "lightgrey"}
]
}
}
}
]
}
]
}

Decode bitcoin transaction vin address

I'm building a graph of blockchain transactions and have a problem to extract source address for a transaction (output addresses are easy,bundled in the getrawtransaction result).
for example this transaction https://www.blockchain.com/btc/tx/8d787db12e04630a10191772f068fae43d30fbb93e6198e7efa636ce03f16222?show_adv=true
the getrawtransaction has an output of
{
"result": {
"txid": "8d787db12e04630a10191772f068fae43d30fbb93e6198e7efa636ce03f16222",
"hash": "7a0a667bf96d65a11eeab8ec17e232c5afdbe724b6e5e60697790bde3037c2c8",
"version": 2,
"size": 248,
"vsize": 166,
"weight": 662,
"locktime": 597359,
"vin": [
{
"txid": "2a1dda8fb17cdcefb26a377492aff6076bd03a93f742d595df1d0ff4951a4305",
"vout": 0,
"scriptSig": {
"asm": "00140d9cad5ccd91bf6ed56ec6bcb7762ec52ecb7b8d",
"hex": "1600140d9cad5ccd91bf6ed56ec6bcb7762ec52ecb7b8d"
},
"txinwitness": [
"3045022100f2900ede33aab8838464cfb127a962960c29cd97ba62e830c69a38621514d2980220706aa5c28d6e1a134f74b99e6280b357dc1f20ae00f4fcca12ab4ccfab5ceac701",
"033b18a261c30edaf859dc523700f3a6085a413ab51b4f63ca84d26073e8e7c709"
],
"sequence": 4294967294
}
],
"vout": [
{
"value": 0.16957303,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 d45c146bdb6ad9c61f3300341e2524e8e64394ac OP_EQUAL",
"hex": "a914d45c146bdb6ad9c61f3300341e2524e8e64394ac87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"3M3sV2VBqPXzZHkbdBXo9dMpEw7xxHCFow"
]
}
},
{
"value": 0.07866618,
"n": 1,
"scriptPubKey": {
"asm": "OP_HASH160 69f37417a9fb77744ec258ac2ff22e99266ac354 OP_EQUAL",
"hex": "a91469f37417a9fb77744ec258ac2ff22e99266ac35487",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"3BMEX8XxUxyEKfRDAJmSMhyd3Y7QWh7PQV"
]
}
}
],
"hex": "0200000000010105431a95f40f1ddf95d542f7933ad06b07f6af9274376ab2efdc7cb18fda1d2a00000000171600140d9cad5ccd91bf6ed56ec6bcb7762ec52ecb7b8dfeffffff0277bf02010000000017a914d45c146bdb6ad9c61f3300341e2524e8e64394ac87fa0878000000000017a91469f37417a9fb77744ec258ac2ff22e99266ac3548702483045022100f2900ede33aab8838464cfb127a962960c29cd97ba62e830c69a38621514d2980220706aa5c28d6e1a134f74b99e6280b357dc1f20ae00f4fcca12ab4ccfab5ceac70121033b18a261c30edaf859dc523700f3a6085a413ab51b4f63ca84d26073e8e7c7096f1d0900",
"blockhash": "00000000000000000002726a175241b0f200c561daf30c668d8652cf3b949343",
"confirmations": 18,
"time": 1569914555,
"blocktime": 1569914555
},
"error": null,
"id": null
}
the source address per blockchain explorer is 36UuEDoDQX5JppSVnpaccV5DCKiquRyPxB. Was not able to derive it from any of the vin fields.
You can decode scriptSig to get the address.
There is a RPC call in bitcoin core that can help you achieve this: decodescript.