示例#1
0
    def test_put_multi_sig_addresses_state(self):
        alice_xmss = get_alice_xmss()
        bob_xmss = get_bob_xmss()
        random_xmss = get_random_xmss()

        signatories = [alice_xmss.address, bob_xmss.address]
        weights = [20, 20]
        threshold = 21
        multi_sig_tx = MultiSigCreate.create(signatories, weights, threshold,
                                             0, random_xmss.pk)
        multi_sig_tx.sign(random_xmss)
        multi_sig_address_state = MultiSigAddressState.get_default(
            multi_sig_tx.txhash, signatories, weights, threshold)

        multi_sig_addresses_state = {
            multi_sig_address_state.address: multi_sig_address_state
        }
        AddressState.put_addresses_state(self.state, multi_sig_addresses_state)

        multi_sig_address_state2 = MultiSigAddressState.get_multi_sig_address_state_by_address(
            self.state._db,
            MultiSigAddressState.generate_multi_sig_address(
                multi_sig_tx.txhash))
        self.assertEqual(multi_sig_address_state.pbdata,
                         multi_sig_address_state2.pbdata)
示例#2
0
    def apply(self, state: State, state_container: StateContainer) -> bool:
        address_state = state_container.addresses_state[self.addr_from]
        address_state.update_balance(state_container, self.fee, subtract=True)
        state_container.paginated_tx_hash.insert(address_state, self.txhash)

        multi_sig_address_state = MultiSigAddressState.get_default(
            self.txhash, self.signatories, self.weights, self.threshold)
        state_container.addresses_state[
            multi_sig_address_state.address] = multi_sig_address_state
        state_container.paginated_tx_hash.insert(multi_sig_address_state,
                                                 self.txhash)

        addr_from_pk = bytes(QRLHelper.getAddress(self.PK))
        for index in range(0, len(self.signatories)):
            signatory = self.signatories[index]
            address_state = state_container.addresses_state[signatory]
            if signatory not in (self.addr_from, addr_from_pk):
                state_container.paginated_tx_hash.insert(
                    address_state, self.txhash)
            state_container.paginated_multisig_address.insert(
                address_state, multi_sig_address_state.address)

        return self._apply_state_changes_for_PK(state_container)