Hotfix - fix threshold_weight calculation in redeem scripts

This commit is contained in:
Srdjan Obucina 2020-04-22 18:01:53 +02:00
parent 9db4615698
commit 8d7e574aa5

View file

@ -263,7 +263,7 @@ void btc_weighted_multisig_address::create_redeem_script(const std::vector<std::
builder << op::ADD; builder << op::ADD;
builder << op::ENDIF; builder << op::ENDIF;
} }
uint32_t threshold_weight = 2 * total_weight / 3; uint32_t threshold_weight = total_weight * 2 / 3 + 1;
builder << threshold_weight; builder << threshold_weight;
builder << op::GREATERTHANOREQUAL; builder << op::GREATERTHANOREQUAL;
@ -379,7 +379,7 @@ void btc_one_or_weighted_multisig_address::create_redeem_script(const fc::ecc::p
builder << op::ADD; builder << op::ADD;
builder << op::ENDIF; builder << op::ENDIF;
} }
uint32_t threshold_weight = 2 * total_weight / 3; uint32_t threshold_weight = total_weight * 2 / 3 + 1;
builder << threshold_weight; builder << threshold_weight;
builder << op::GREATERTHANOREQUAL; builder << op::GREATERTHANOREQUAL;
builder << op::ENDIF; builder << op::ENDIF;
@ -445,7 +445,7 @@ void btc_timelocked_one_or_weighted_multisig_address::create_redeem_script(const
builder << op::ADD; builder << op::ADD;
builder << op::ENDIF; builder << op::ENDIF;
} }
uint32_t threshold_weight = 2 * total_weight / 3; uint32_t threshold_weight = total_weight * 2 / 3 + 1;
builder << threshold_weight; builder << threshold_weight;
builder << op::GREATERTHANOREQUAL; builder << op::GREATERTHANOREQUAL;
builder << op::ENDIF; builder << op::ENDIF;