| 
						
						
							
								
							
						
						
					 | 
					 | 
					@ -1437,11 +1437,11 @@ static void gbt_witness_data(workbase_t *wb, json_t *txn_array) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 * are serialised. */ | 
					 | 
					 | 
					 | 
					 * are serialised. */ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					static void block_update(ckpool_t *ckp, int *prio) | 
					 | 
					 | 
					 | 
					static void block_update(ckpool_t *ckp, int *prio) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					{ | 
					 | 
					 | 
					 | 
					{ | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						const char* witnessdata_check, *rule; | 
					 | 
					 | 
					 | 
						const char *witnessdata_check; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						json_t *txn_array, *rules_array; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						sdata_t *sdata = ckp->sdata; | 
					 | 
					 | 
					 | 
						sdata_t *sdata = ckp->sdata; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						bool new_block = false; | 
					 | 
					 | 
					 | 
						bool new_block = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						int i, retries = 0; | 
					 | 
					 | 
					 | 
						int i, retries = 0; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
					 | 
						json_t *txn_array; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						bool ret = false; | 
					 | 
					 | 
					 | 
						bool ret = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						txntable_t *txns; | 
					 | 
					 | 
					 | 
						txntable_t *txns; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						workbase_t *wb; | 
					 | 
					 | 
					 | 
						workbase_t *wb; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					 | 
					@ -1465,29 +1465,17 @@ retry: | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						txns = wb_merkle_bin_txns(ckp, sdata, wb, txn_array, true); | 
					 | 
					 | 
					 | 
						txns = wb_merkle_bin_txns(ckp, sdata, wb, txn_array, true); | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						wb->insert_witness = false; | 
					 | 
					 | 
					 | 
						wb->insert_witness = false; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						rules_array = json_object_get(wb->json, "rules"); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						if (rules_array) { | 
					 | 
					 | 
					 | 
						witnessdata_check = json_string_value(json_object_get(wb->json, "default_witness_commitment")); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							int rule_count = json_array_size(rules_array); | 
					 | 
					 | 
					 | 
						if (likely(witnessdata_check)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
							LOGDEBUG("Default witness commitment present, adding witness data"); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							for (i = 0; i < rule_count; i++) { | 
					 | 
					 | 
					 | 
							gbt_witness_data(wb, txn_array); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								rule = json_string_value(json_array_get(rules_array, i)); | 
					 | 
					 | 
					 | 
							// Verify against the pre-calculated value if it exists. Skip the size/OP_RETURN bytes.
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (!rule) | 
					 | 
					 | 
					 | 
							if (likely(witnessdata_check)) { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									continue; | 
					 | 
					 | 
					 | 
								if (wb->insert_witness && witnessdata_check[0] && safecmp(witnessdata_check + 4, wb->witnessdata) != 0) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (*rule == '!') | 
					 | 
					 | 
					 | 
									LOGERR("Witness from btcd: %s. Calculated Witness: %s", witnessdata_check + 4, wb->witnessdata); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									rule++; | 
					 | 
					 | 
					 | 
							} else | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								if (safecmp(rule, "segwit")) { | 
					 | 
					 | 
					 | 
								LOGNOTICE("Segwit rules returned but no default_witness_commitment to check witness data"); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									witnessdata_check = json_string_value(json_object_get(wb->json, "default_witness_commitment")); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									gbt_witness_data(wb, txn_array); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									// Verify against the pre-calculated value if it exists. Skip the size/OP_RETURN bytes.
 | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									if (likely(witnessdata_check)) { | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										if (wb->insert_witness && witnessdata_check[0] && safecmp(witnessdata_check + 4, wb->witnessdata) != 0) | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
											LOGERR("Witness from btcd: %s. Calculated Witness: %s", witnessdata_check + 4, wb->witnessdata); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									} else | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
										LOGNOTICE("Segwit rules returned but no default_witness_commitment to check witness data"); | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
									break; | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
								} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
							} | 
					 | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						} | 
					 | 
					 | 
					 | 
						} | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
					
 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					 | 
						generate_coinbase(ckp, wb); | 
					 | 
					 | 
					 | 
						generate_coinbase(ckp, wb); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					 | 
					
  |