when importing electrum wallets retrieve tx labels from address labels

This commit is contained in:
Craig Raw 2021-04-12 16:16:07 +02:00
parent 497cf333b0
commit 9600d5707c

View file

@ -10,9 +10,7 @@ import com.sparrowwallet.drongo.address.Address;
import com.sparrowwallet.drongo.crypto.*; import com.sparrowwallet.drongo.crypto.*;
import com.sparrowwallet.drongo.policy.Policy; import com.sparrowwallet.drongo.policy.Policy;
import com.sparrowwallet.drongo.policy.PolicyType; import com.sparrowwallet.drongo.policy.PolicyType;
import com.sparrowwallet.drongo.protocol.ScriptType; import com.sparrowwallet.drongo.protocol.*;
import com.sparrowwallet.drongo.protocol.Sha256Hash;
import com.sparrowwallet.drongo.protocol.Transaction;
import com.sparrowwallet.drongo.wallet.*; import com.sparrowwallet.drongo.wallet.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -233,6 +231,22 @@ public class Electrum implements KeystoreFileImport, WalletImport, WalletExport
} }
} }
} }
for(BlockTransaction blkTx : ew.transactions.values()) {
if(blkTx.getLabel() == null) {
Transaction tx = blkTx.getTransaction();
for(TransactionOutput txOutput : tx.getOutputs()) {
try {
Address[] addresses = txOutput.getScript().getToAddresses();
if(Arrays.asList(addresses).contains(address)) {
blkTx.setLabel(ew.labels.get(key));
}
} catch(NonStandardScriptException ex) {
//ignore
}
}
}
}
} catch(Exception ex) { } catch(Exception ex) {
//not an address //not an address
} }