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

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?

Related

I keep getting 400 error(travelerId not existing) on calling the CreateOrder API

I am on a test Account.
On printing the travelerPricings Object to console, I have this
[
{
travelerId: '1',
fareOption: 'STANDARD',
travelerType: 'ADULT',
price: {
currency: '',
total: '',
base: '',
taxes: [Array],
refundableTaxes: ''
},
fareDetailsBySegment: [ [Object], [Object], [Object], [Object] ]
},
{
travelerId: '2',
fareOption: 'STANDARD',
travelerType: 'CHILD',
price: {
currency: '',
total: '',
base: '',
taxes: [Array],
refundableTaxes: ''
},
fareDetailsBySegment: [ [Object], [Object], [Object], [Object] ]
}
]
Yet on the Api Response, I keep getting the error pointer as
/data/flightOffers[0]/travelerPricings[1]"
Which is not true. As seen in the log shared above,
travelerPricings[1].travelerId = '2'
Please Why could this error come up? Thanks
Based on the Request, Here is the sample payload
{"data":
{
"flightOffers": [
{
"type": "flight-offer",
"id": "1",
"source": "GDS",
"instantTicketingRequired": false,
"nonHomogeneous": false,
"paymentCardRequired": false,
"lastTicketingDate": "2022-08-01",
"itineraries": [
{
"segments": [
{
"departure": {
"iataCode": "SYD",
"terminal": "1",
"at": "2022-08-01T11:35:00"
},
"arrival": {
"iataCode": "MNL",
"terminal": "2",
"at": "2022-08-01T16:50:00"
},
"carrierCode": "PR",
"number": "212",
"aircraft": {
"code": "333"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT7H15M",
"id": "15",
"numberOfStops": 0,
"co2Emissions": [
{
"weight": 716,
"weightUnit": "KG",
"cabin": "BUSINESS"
}
]
},
{
"departure": {
"iataCode": "MNL",
"terminal": "1",
"at": "2022-08-01T19:20:00"
},
"arrival": {
"iataCode": "BKK",
"at": "2022-08-01T21:50:00"
},
"carrierCode": "PR",
"number": "732",
"aircraft": {
"code": "320"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT3H30M",
"id": "16",
"numberOfStops": 0,
"co2Emissions": [
{
"weight": 148,
"weightUnit": "KG",
"cabin": "BUSINESS"
}
]
}
]
},
{
"segments": [
{
"departure": {
"iataCode": "BKK",
"at": "2022-08-05T22:50:00"
},
"arrival": {
"iataCode": "MNL",
"terminal": "2",
"at": "2022-08-06T03:15:00"
},
"carrierCode": "PR",
"number": "733",
"aircraft": {
"code": "321"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT3H25M",
"id": "59",
"numberOfStops": 0,
"co2Emissions": [
{
"weight": 148,
"weightUnit": "KG",
"cabin": "ECONOMY"
}
]
},
{
"departure": {
"iataCode": "MNL",
"terminal": "1",
"at": "2022-08-06T22:10:00"
},
"arrival": {
"iataCode": "SYD",
"terminal": "1",
"at": "2022-08-07T09:45:00"
},
"carrierCode": "PR",
"number": "211",
"aircraft": {
"code": "333"
},
"operating": {
"carrierCode": "PR"
},
"duration": "PT9H35M",
"id": "60",
"numberOfStops": 0,
"co2Emissions": [
{
"weight": 358,
"weightUnit": "KG",
"cabin": "ECONOMY"
}
]
}
]
}
],
"price": {
"currency": "NGN",
"total": "1479460.00",
"base": "1298255.00",
"fees": [
{
"amount": "0.00",
"type": "SUPPLIER"
},
{
"amount": "0.00",
"type": "TICKETING"
},
{
"amount": "0.00",
"type": "FORM_OF_PAYMENT"
}
],
"grandTotal": "1479460.00",
"billingCurrency": "NGN"
},
"pricingOptions": {
"fareType": [
"PUBLISHED"
],
"includedCheckedBagsOnly": false
},
"validatingAirlineCodes": [
"PR"
],
"travelerPricings": [
{
"travelerId": "1",
"fareOption": "STANDARD",
"travelerType": "ADULT",
"price": {
"currency": "NGN",
"total": "840536",
"base": "740769",
"taxes": [
{
"amount": "384.00",
"code": "G8"
},
{
"amount": "19112.00",
"code": "WY"
},
{
"amount": "896.00",
"code": "E7"
},
{
"amount": "18329.00",
"code": "AU"
},
{
"amount": "42766.00",
"code": "YQ"
},
{
"amount": "9320.00",
"code": "LI"
},
{
"amount": "8960.00",
"code": "TS"
}
],
"refundableTaxes": "108123"
},
"fareDetailsBySegment": [
{
"segmentId": "15",
"cabin": "BUSINESS",
"fareBasis": "DBAU",
"class": "D",
"includedCheckedBags": {
"weight": 40,
"weightUnit": "KG"
}
},
{
"segmentId": "16",
"cabin": "BUSINESS",
"fareBasis": "DBAU",
"class": "D",
"includedCheckedBags": {
"weight": 40,
"weightUnit": "KG"
}
},
{
"segmentId": "59",
"cabin": "ECONOMY",
"fareBasis": "KBAU",
"class": "K",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
},
{
"segmentId": "60",
"cabin": "ECONOMY",
"fareBasis": "KBAU",
"class": "K",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
}
]
},
{
"travelerId": "2",
"fareOption": "STANDARD",
"travelerType": "CHILD",
"price": {
"currency": "NGN",
"total": "638924",
"base": "557486",
"taxes": [
{
"amount": "384.00",
"code": "G8"
},
{
"amount": "19112.00",
"code": "WY"
},
{
"amount": "896.00",
"code": "E7"
},
{
"amount": "42766.00",
"code": "YQ"
},
{
"amount": "9320.00",
"code": "LI"
},
{
"amount": "8960.00",
"code": "TS"
}
],
"refundableTaxes": "89794"
},
"fareDetailsBySegment": [
{
"segmentId": "15",
"cabin": "BUSINESS",
"fareBasis": "DBAU",
"class": "D",
"includedCheckedBags": {
"weight": 40,
"weightUnit": "KG"
}
},
{
"segmentId": "16",
"cabin": "BUSINESS",
"fareBasis": "DBAU",
"class": "D",
"includedCheckedBags": {
"weight": 40,
"weightUnit": "KG"
}
},
{
"segmentId": "59",
"cabin": "ECONOMY",
"fareBasis": "KBAU",
"class": "K",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
},
{
"segmentId": "60",
"cabin": "ECONOMY",
"fareBasis": "KBAU",
"class": "K",
"includedCheckedBags": {
"weight": 30,
"weightUnit": "KG"
}
}
]
}
]
}
],
"travelers": [ {
"id": "1",
"dateOfBirth": "1982-01-16",
"name": {
"firstName": "JORGE",
"lastName": "GONZALES"
},
"gender": "MALE",
"contact": {
"emailAddress": "jorge.gonzales833#telefonica.es",
"phones": [ {
"deviceType": "MOBILE",
"countryCallingCode": "34",
"number": "480080076"
} ]
},
"documents": [ {
"documentType": "PASSPORT",
"birthPlace": "Madrid",
"issuanceLocation": "Madrid",
"issuanceDate": "2015-04-14",
"number": "00000000",
"expiryDate": "2025-04-14",
"issuanceCountry": "ES",
"validityCountry": "ES",
"nationality": "ES",
"holder": true
} ]
} ]
}
MY Request using the NodeSDK
const {data:{flightOffers}} = req.body;
const {result} = await Amadeus.booking.flightOrders.post(
JSON.stringify({
'data': {
'type': 'flight-order',
'flightOffers': [ flightOffers[ 0 ] ],
'travelers': travelers
}
})
);
This is quite lengthy, but I did this so it is easy to just re-create the exact Scenario in case the issue is somewhere in the payload I am sending.
When you request Flight Create Order API, you have only put 1 traveler's information at the end that's why the error comes. you are requesting for flight order for 2 persons (1 adult and 1 child) so both information should be attached at the end.
below is a node example for the entire flow from Flight offer search, pricing, and create order. you may get a different error if some segments are not available, but the issue that you faced regarding travelers is resolved.
amadeus.shopping.flightOffersSearch.get({
originLocationCode: 'SYD',
destinationLocationCode: 'BKK',
departureDate: '2022-08-01',
adults: '1',
children: '1'
}).then(function (flightOffersResponse) {
return amadeus.shopping.flightOffers.pricing.post(
JSON.stringify({
'data': {
'type': 'flight-offers-pricing',
'flightOffers': [flightOffersResponse.data[0]]
}
})
)
}).then(function (pricingResponse) {
return amadeus.booking.flightOrders.post(
JSON.stringify({
'data': {
'type': 'flight-order',
'flightOffers': [pricingResponse.data.flightOffers[0]],
'travelers': [{
"id": "1",
"dateOfBirth": "1982-01-16",
"name": {
"firstName": "JORGE",
"lastName": "GONZALES"
},
"gender": "MALE",
"contact": {
"emailAddress": "jorge.gonzales833#telefonica.es",
"phones": [{
"deviceType": "MOBILE",
"countryCallingCode": "34",
"number": "480080076"
}]
},
"documents": [{
"documentType": "PASSPORT",
"birthPlace": "Madrid",
"issuanceLocation": "Madrid",
"issuanceDate": "2015-04-14",
"number": "00000000",
"expiryDate": "2025-04-14",
"issuanceCountry": "ES",
"validityCountry": "ES",
"nationality": "ES",
"holder": true
}]
},
{
"id": "2",
"dateOfBirth": "2012-10-11",
"gender": "FEMALE",
"contact": {
"emailAddress": "jorge.gonzales833#telefonica.es",
"phones": [
{
"deviceType": "MOBILE",
"countryCallingCode": "34",
"number": "480080076"
}
]
},
"name": {
"firstName": "ADRIANA",
"lastName": "GONZALES"
}
}]
}
})
);
}).then(function (response) {
console.log(response);
}).catch(function (response) {
console.error(response);
});

Square API: Object version does not match latest database version

I'm trying to use the following Square API endpoint to update an item, but I'm getting some errors. Here is the item that I'm trying to update.
{
"type": "ITEM",
"id": "7HXK6NVBDKSOK64CCAYZJ2KW",
"updated_at": "2020-08-08T21:43:41.849Z",
"version": 1596923021849,
"is_deleted": false,
"present_at_all_locations": false,
"present_at_location_ids": [
"1JZ5JTPBW0EXY"
],
"item_data": {
"name": "Hummus Plate",
"description": "Olives, feta, tomatoes, tzatziki and warm pita.",
"visibility": "PRIVATE",
"category_id": "ARB5LTTDUSER6T66ZWYO65FL",
"variations": [
{
"type": "ITEM_VARIATION",
"id": "HBIHPLROOJUUNUSW3BZUDQ5J",
"updated_at": "2020-08-08T21:40:14.581Z",
"version": 1596922814581,
"is_deleted": false,
"present_at_all_locations": false,
"present_at_location_ids": [
"1JZ5JTPBW0EXY"
],
"item_variation_data": {
"item_id": "7HXK6NVBDKSOK64CCAYZJ2KW",
"name": "Regular",
"ordinal": 0,
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 1000,
"currency": "USD"
}
}
}
],
"product_type": "REGULAR",
"skip_modifier_screen": true,
"ecom_available": false,
"ecom_visibility": "UNINDEXED"
}
}
Here the body content.
{
"batches": [{
"objects": [{
"type": "ITEM_VARIATION",
"id": "T6KKCATDIU2VV4BDBMVGML4W",
"item_variation_data": {
"item_id": "FNWWGFTBQWFAYK6JGBD3LDLD",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 150,
"currency": "USD"
}
}
}]
}],
"idempotency_key": "61994762-3a6s-4b75-sf81-fdfaf"
}
Here is the error I'm getting:
**{
"errors": [
{
"category": "INVALID_REQUEST_ERROR",
"code": "VERSION_MISMATCH",
"detail": "Object version does not match latest database version.",
"field": "version"
}
]
}**
I'm not sure what I'm doing wrong, but I appreciate any help I can get. Thank you in advance!
When updating a catalog object in Square, you need to provide the latest version number in the request.
{
"batches": [{
"objects": [{
"type": "ITEM_VARIATION",
"id": "T6KKCATDIU2VV4BDBMVGML4W",
"version": "12345",
"item_variation_data": {
"item_id": "FNWWGFTBQWFAYK6JGBD3LDLD",
"pricing_type": "FIXED_PRICING",
"price_money": {
"amount": 150,
"currency": "USD"
}
}
}]
}],
"idempotency_key": "61994762-3a6s-4b75-sf81-fdfaf"
}

extra bag information is missing in the flight offer price response

I'm testing self-service APIs. I wonder if this is a bug:
I make a search request, and the response contains the extra bag information in the flight-offer/price/additionalServices
Then I make the offer price request by adding include=bags parameter in the path of Flight Offers Price API.
However there is no any bags information in the response, neither in the offer/price/additionalServices, nor in the included/.
I still try to create order by adding the extra bag. So I use the extra bag information that I got at step 1 (search response). And the order is created successfully.
It seems that the extra bag information is missing in step 2 (response of flight offer price), is it a bug?
Here is an example of my test to reproduce the issue:
search request
{
"currencyCode": "EUR",
"originDestinations": [
{
"id": "1",
"originLocationCode": "PAR",
"destinationLocationCode": "NYC",
"departureDateTimeRange": {
"date": "2020-08-20",
"time": "10:00:00"
}
}
],
"travelers": [
{
"id": "1",
"travelerType": "ADULT"
}
],
"sources": [
"GDS"
],
"searchCriteria": {
"maxFlightOffers": 3
}
}
Then I select the second offer in the response to make a offer price request using include=bags parameter
{
"type": "flight-offer",
"id": "2",
"source": "GDS",
"instantTicketingRequired": false,
"nonHomogeneous": false,
"oneWay": false,
"lastTicketingDate": "2020-08-13",
"numberOfBookableSeats": 8,
"itineraries": [
{
"duration": "PT8H15M",
"segments": [
{
"departure": {
"iataCode": "ORY",
"terminal": "4",
"at": "2020-08-20T19:45:00"
},
"arrival": {
"iataCode": "EWR",
"terminal": "B",
"at": "2020-08-20T22:00:00"
},
"carrierCode": "TX",
"number": "6720",
"aircraft": {
"code": "359"
},
"operating": {
"carrierCode": "BF"
},
"duration": "PT8H15M",
"id": "3",
"numberOfStops": 0,
"blacklistedInEU": false
}
]
}
],
"price": {
"currency": "EUR",
"total": "149.44",
"base": "41.00",
"fees": [
{
"amount": "0.00",
"type": "SUPPLIER"
},
{
"amount": "0.00",
"type": "TICKETING"
}
],
"grandTotal": "149.44",
"additionalServices": [
{
"amount": "70.00",
"type": "CHECKED_BAGS"
}
]
},
"pricingOptions": {
"fareType": [
"PUBLISHED"
],
"includedCheckedBagsOnly": false
},
"validatingAirlineCodes": [
"TX"
],
"travelerPricings": [
{
"travelerId": "1",
"fareOption": "STANDARD",
"travelerType": "ADULT",
"price": {
"currency": "EUR",
"total": "149.44",
"base": "41.00"
},
"fareDetailsBySegment": [
{
"segmentId": "3",
"cabin": "ECONOMY",
"fareBasis": "ULBCOWFR",
"brandedFare": "EBASIC",
"class": "U",
"includedCheckedBags": {
"quantity": 0
}
}
]
}
]
}
There is no extra bag in the response.
Thanks

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.

Parsing Twitter Information with jq ("text": null)

I am trying to do some Twitter-analysis via Twurl and extract some information via jq.
I firstly get some tweets via twurl with the command
twurl /1.1/users/search.json?q=judo
Then i used the following line to structure the outpot with jq:
twurl /1.1/users/search.json?q=judo | jq
i get something like this:
[
{
"id": 173752759,
"id_str": "173752759",
"name": "#JudoWorlds πŸ₯‹",
"screen_name": "Judo",
"location": "Worldwide",
"description": "The Official Twitter Account of the International Judo Federation πŸ₯‹",
"url": "https:.....",
"entities": {
"url": {
"urls": [
{
"url": "https://......",
"expanded_url": "https://www.ijf.org/news/show/5-must-see-preliminary-round-clashes-2",
"display_url": "ijf.org/news/show/5-mu…",
"indices": [
0,
23
]
}
]
},
"description": {
"urls": []
}
},
"protected": false,
"followers_count": 59854,
"friends_count": 847,
"listed_count": 529,
"created_at": "Mon Aug 02 07:55:15 +0000 2010",
"favourites_count": 7074,
"utc_offset": null,
"time_zone": null,
"geo_enabled": true,
"verified": true,
"statuses_count": 16532,
"lang": null,
"status": {
"created_at": "Fri Aug 30 08:27:10 +0000 2019",
"id": 1167353053282013200,
"id_str": "1167353053282013184",
"text": "#JudoWorlds The Alternative Promo \n\n#NeilAdamsJudo https://.....",
"truncated": false,
"entities": {
"hashtags": [
{
"text": "JudoWorlds",
"indices": [
0,
11
]
}
],
"symbols": [],
"user_mentions": [
{
"screen_name": "NeilAdamsJudo",
"name": "Neil Adams MBE",
"id": 40488733,
"id_str": "40488733",
"indices": [
36,
50
]
}
],
"urls": [],
"media": [
{
"id": 1167352899267002400,
"id_str": "1167352899267002369",
"indices": [
51,
74
],
"media_url": "http://pbs.twimg.com/ext_tw_video_thumb/1167352899267002369/pu/img/6yD1r7uaPV7p3y6a.jpg",
"media_url_https": "https://pbs.twimg.com/ext_tw_video_thumb/1167352899267002369/pu/img/6yD1r7uaPV7p3y6a.jpg",
"url": "https://......",
"display_url": "pic.twitter.com/0RlLbKLkN8",
"expanded_url": "https://twitter.com/Judo/status/1167353053282013184/video/1",
"type": "photo",
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"medium": {
"w": 1200,
"h": 675,
"resize": "fit"
},
"small": {
"w": 680,
"h": 383,
"resize": "fit"
},
"large": {
"w": 1280,
"h": 720,
"resize": "fit"
}
}
}
]
},
"extended_entities": {
"media": [
{
"id": 1167352899267002400,
"id_str": "1167352899267002369",
"indices": [
51,
74
],
"media_url": "http://pbs.twimg.com/ext_tw_video_thumb/1167352899267002369/pu/img/6yD1r7uaPV7p3y6a.jpg",
"media_url_https": "https://pbs.twimg.com/ext_tw_video_thumb/1167352899267002369/pu/img/6yD1r7uaPV7p3y6a.jpg",
"url": "https://.....",
"display_url": "pic.twitter.com/0RlLbKLkN8",
"expanded_url": "https://twitter.com/Judo/status/1167353053282013184/video/1",
"type": "video",
"sizes": {
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"medium": {
"w": 1200,
"h": 675,
"resize": "fit"
},
"small": {
"w": 680,
"h": 383,
"resize": "fit"
},
"large": {
"w": 1280,
"h": 720,
"resize": "fit"
}
},
"video_info": {
"aspect_ratio": [
16,
9
],
"duration_millis": 48800,
"variants": [
{
"bitrate": 256000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1167352899267002369/pu/vid/480x270/v4nkTg6qs9rpLq8M.mp4?tag=10"
},
{
"content_type": "application/x-mpegURL",
"url": "https://video.twimg.com/ext_tw_video/1167352899267002369/pu/pl/SQN57QxQFYcKWV7l.m3u8?tag=10"
},
{
"bitrate": 2176000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1167352899267002369/pu/vid/1280x720/8cyNocB_8CRjwVCI.mp4?tag=10"
},
{
"bitrate": 832000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/1167352899267002369/pu/vid/640x360/uy2U7D_AEmbLdqEK.mp4?tag=10"
}
]
},
"additional_media_info": {
"monetizable": false
}
}
]
},
"source": "Twitter for Android",
"in_reply_to_status_id": null,
"in_reply_to_status_id_str": null,
"in_reply_to_user_id": null,
"in_reply_to_user_id_str": null,
"in_reply_to_screen_name": null,
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"is_quote_status": false,
"retweet_count": 4,
"favorite_count": 17,
"favorited": false,
"retweeted": false,
"possibly_sensitive": false,
"lang": "en"
},
"contributors_enabled": false,
"is_translator": false,
"is_translation_enabled": false,
"profile_background_color": "0099CC",
"profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
"profile_background_tile": false,
"profile_image_url": "http://pbs.twimg.com/profile_images/1057928008797970433/O3l2sKj0_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/1057928008797970433/O3l2sKj0_normal.jpg",
"profile_banner_url": "https://pbs.twimg.com/profile_banners/173752759/1565853008",
"profile_link_color": "0C3C42",
"profile_sidebar_border_color": "8F320A",
"profile_sidebar_fill_color": "F2CF41",
"profile_text_color": "000000",
"profile_use_background_image": true,
"has_extended_profile": false,
"default_profile": false,
"default_profile_image": false,
"following": false,
"follow_request_sent": false,
"notifications": false,
"translator_type": "none"
},
Because i am only interested in certain informations i tried to get the name and the text of the tweet with the following command:
twurl /1.1/users/search.json?q=judo | jq ".[] | { name: .name, text: .text }"
and i get this:
{
"name": "#JudoWorlds πŸ₯‹",
"text": null
}
{
"name": "#WeAreGBJudo",
"text": null
}
{
"name": "CBJ",
"text": null
}
{
"name": "Santos Futebol Clube",
"text": null
}
{
"name": "Marius Vizer",
"text": null
}
{
"name": "FF Judo",
"text": null
}
{
"name": "Santos FC πŸ‡Ί πŸ‡Έ πŸ‡¬ πŸ‡§ ",
"text": null
}
{
"name": "USA Judo",
"text": null
}
{
"name": "ε…¨ζ—₯ζœ¬ζŸ”ι“ι€£η›Ÿ -ゴジラジャパン-",
"text": null
}
{
"name": "Vila Belmiro",
"text": null
}
{
"name": "Deutscher Judo-Bund",
"text": null
}
{
"name": "Bruno Secco",
"text": null
}
{
"name": "Bobby Judo",
"text": null
}
{
"name": "African Judo Union",
"text": null
}
{
"name": "JudoInside.com",
"text": null
}
{
"name": "For competitive judo",
"text": null
}
{
"name": "Judo Canada",
"text": null
}
{
"name": "Neil Adams MBE",
"text": null
}
{
"name": "Sophie Cox",
"text": null
}
{
"name": "Galatasaray Judo",
"text": null
}
Why is this and how can i fix it?
I tried other commands like :
twurl /1.1/search/tweets.json?q=afd | jq ".[] | { name: .name, text: .text }"
but got the error
jq: error (at <stdin>:0): Cannot index array with string "name"
If you need nested 'text' value from 'status' field you should use:
.[] | { name: .name, text: .status.text }
Or shorter version:
.[] | { name, text: .status.text }